# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
18815 | ggoh | Last supper (IOI12_supper) | C++98 | 264 ms | 13280 KiB |
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 "advisor.h"
int o,ch[100002],go[100002],late[100002],st[100002],color[100002];
void write(int q)
{
int pp=o;
while(pp)
{
WriteAdvice(q%2);
pp--;
q/=2;
}
}
void ComputeAdvice(int *C, int N, int K, int M)
{
int u=K,p;
int t=0,sz=0,on;
u--;
while(u)
{
u/=2;o++;
}
if(K==1)o=1;
for(int i=0;i<N;i++)color[i]=C[i],late[i]=-1;
t=0;
for(int i=0;i<N;i++)
{
late[color[i]]=i;
}
for(int i=0;i<K;i++)
{
ch[i]=1;
on=i;
go[i]=i;
if(late[i]==-1)st[t++]=i;
}
for(int i=0;i<N;i++)
{
if(ch[color[i]]==1)
{
if(late[color[i]]==i)
{
late[color[i]]=-1;
st[t++]=color[i];
}
}
else
{
if(t)
{
t--;
write(go[st[t]]);
go[color[i]]=go[st[t]];
ch[st[t]]=0;
ch[color[i]]=1;
on=color[i];
}
else
{
write(go[on]);
go[color[i]]=go[on];
ch[on]=0;
on=color[i];
ch[on]=1;
}
if(late[color[i]]==i)
{
late[color[i]]=-1;
st[t++]=color[i];
}
}
}
}
#include "assistant.h"
int ch[100002],st[100002];
void Assist(unsigned char *A, int N, int K, int R)
{
int o=0,p,u=K,r;
u--;
while(u)
{
u/=2;o++;
}
if(K==1)o=1;
for(int i=0;i<K;i++)st[i]=i,ch[i]=1;
u=0;
for(int i=0;i<N;i++)
{
p=GetRequest();
if(ch[p])continue;
r=0;
for(int j=0;j<o;j++)
{
r+=A[u+j]*(1<<j);
}
PutBack(st[r]);
ch[st[r]]=0;
st[r]=p;
ch[p]=1;
}
}
Compilation message (stderr)
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |