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 <queue>
using namespace std;
int ing[8],have,ordernumber;
queue<int> orderlist[1<<8];
void Init(){
int i;
for (i=0;i<(1<<8);i++) while (!orderlist[i].empty()) orderlist[i].pop();
for (i=0;i<8;i++) ing[i] = 0;
have = ordernumber = 0;
}
void Order(int N, int *A) {
int what = 0, i;
for (i=0;i<N;i++) what += 1 << A[i];
if ((have & what) == what){
for (i=0;i<N;i++){
if (--ing[A[i]] == 0) have -= 1 << A[i];
}
Bake(ordernumber);
}
else orderlist[what].push(ordernumber);
ordernumber++;
}
void Delivery(int I) {
int i,num=ordernumber,x;
if (ing[I]++ == 0){
have += 1 << I;
for (i=have;i;i=have&(i-1)){
if (!orderlist[i].empty()){
if (num > orderlist[i].front()){
num = orderlist[i].front();
x = i;
}
}
}
if (num < ordernumber){
for (i=0;i<8;i++) if (x & (1 << i)){
if (--ing[i] == 0) have -= 1 << i;
}
Bake(num);
orderlist[x].pop();
}
}
}
# | 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... |