123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- #include "instance.h"
- using namespace std;
- int next(instance &ins) {
- int best;
- for(int i = 0; i < ins.orders.size(); i++) {
- if(!ins.orders[i].ord.empty()) {
- best = i;
- break;
- }
- }
- return best;
- }
- void glouton(instance &ins) {
- int tour = 1000;
- cout << 2*tour << endl;
- for(int i = 0; i < tour; i++) {
- int next_i = next(ins);
- int drone = rand()%ins.drones;
- order &ord = ins.orders[next_i];
- assert(!ord.ord.empty());
- pair<const int, int> &type = *ord.ord.begin();
- int wa = ins.find(pos(0, 0), type.first);
- int quantity = min(type.second, ins.max_load/ins.weights[type.first]);
- quantity = min(quantity, ins.wh[wa].disp[type.first]);
- ins.wh[wa].disp[type.first] -= quantity;
- // decrease order / stock
- type.second -= quantity;
- if(!type.second)
- ord.ord.erase(type.first);
- // pass order
- cout << drone << " L " << wa << " " << type.first << " " << quantity << endl;
- cout << drone << " D " << next_i << " " << type.first << " " << quantity << endl;
- }
- }
- int main() {
- srand(time(NULL));
- instance ins;
- glouton(ins);
- return 0;
- }
|