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>
std::queue<int> q[256];
int num[8];
int s;
int c;
void Init()
{
}
void Order(int n, int *a)
{
bool u=1;
int i;
for(i=0;i<n;i++)
{
if(!num[a[i]])
{
u=0;
break;
}
}
if(u)
{
Bake(c);
for(i=0;i<n;i++)
{
num[a[i]]--;
if(!num[a[i]])
s^=(1<<a[i]);
}
}
else
{
int r=0;
for(i=0;i<n;i++)
r|=(1<<a[i]);
q[r].push(c);
}
c++;
}
void Delivery(int a)
{
if(!num[a])
s|=(1<<a);
num[a]++;
if(num[a]==1)
{
int m=100000,r,i;
for(i=s;i>=1;i=(i-1)&s)
{
if(!(i&(1<<a)))
continue;
if(!q[i].empty()&&q[i].front()<m)
{
m=q[i].front();
r=i;
}
}
if(m!=100000)
{
Bake(q[r].front());
q[r].pop();
for(i=0;i<8;i++)
{
if(r&(1<<i))
{
num[i]--;
if(!num[i])
s^=(1<<i);
}
}
}
}
}
# | 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... |