This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///
#include "pizza.h"
#include <deque>
#include <utility>
using namespace std;
typedef pair<int,int> pi;
deque<pi> dq[256];
int order_num;
int ingredients[8], ingnow;
void Init() {
order_num = 0;
}
int processed[100005];
void deliver(){
while (1) {
while (!dq[ingnow].empty() && processed[dq[ingnow].front().first]) {
dq[ingnow].pop_front();
}
if(!dq[ingnow].empty()){
processed[dq[ingnow].front().first] = 1;
Bake(dq[ingnow].front().first);
int t = dq[ingnow].front().second;
dq[ingnow].pop_front();
for (int i=0; i<8; i++) {
if((t>>i)&1){
ingredients[i]--;
if(ingredients[i] == 0) ingnow ^= (1<<i);
}
}
}
else break;
}
}
void Order(int N, int *A) {
int bitfield = 0;
for (int i=0; i<N; i++) {
bitfield |= (1 << A[i]);
}
for (int i=0; i<256; i++) {
if((bitfield & ~i) == 0){
dq[i].push_back(pi(order_num,bitfield));
}
}
order_num++;
deliver();
}
void Delivery(int I) {
ingredients[I]++;
if(ingredients[I] == 1) ingnow |= (1<<I), deliver();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |