This repository has been archived on 2019-08-08. You can view files and clone it, but cannot push or open issues or pull requests.
hashcode2016/reborn.py

122 lines
2.3 KiB
Python
Executable file

#!/usr/bin/env python3
import sys
class Product:
ALL = []
def __init__(self, weight):
self.ALL.append(self)
self.weight = weight
def weight(pid):
return __class__.ALL[pid].weight
def get(pid):
return __class__.ALL[pid]
def len():
return len(__class__.ALL)
class Warehouse:
ALL = []
def __init__(self, pos, items):
self.ALL.append(self)
self.pos = pos
self.items = items
def get(pid):
return __class__.ALL[pid]
def len():
return len(__class__.ALL)
class Client:
ALL = []
def __init__(self, pos, needs):
self.ALL.append(self)
self.pos = pos
self.items = needs
def get(pid):
return __class__.ALL[pid]
def len():
return len(__class__.ALL)
class Drone:
ALL = []
PAYLOAD = 0
def __init__(self):
self.ALL.append(self)
self.pos = Warehouse.get(0).pos
self.items = []
self.avail = 0
self.tasks = []
def get(pid):
return __class__.ALL[pid]
def len():
return len(__class__.ALL)
X = 0 # Nb rows
Y = 0 # Nb columns
T = 0 # Deadline
def readFile(filename):
global X, Y, T
with open(filename, 'r') as f:
# Parameters
X, Y, D, T, Drone.PAYLOAD = [int(i) for i in f.readline().split(' ')]
# Products
P = int(f.readline())
weights = f.readline().split(' ')
assert(len(weights) == P)
for w in weights:
Product(w)
# Warehouses
for i in range(0, int(f.readline())):
pos = [int(i) for i in f.readline().split(' ')]
qtItems = [int(i) for i in f.readline().split(' ')]
assert(len(qtItems) == P)
items = []
for p in range(P):
for i in range(qtItems[p]):
items.append(p)
Warehouse(pos, items)
# Clients
for i in range(0, int(f.readline())):
pos = [int(i) for i in f.readline().split(' ')]
N = int(f.readline())
needs = [int(i) for i in f.readline().split(' ')]
assert(len(needs) == N)
Client(pos, needs)
# Create drones
for d in range(D):
Drone()
readFile(sys.argv[1])