Submission #18817

# Submission time Handle Problem Language Result Execution time Memory
18817 2016-02-15T22:08:01 Z ggoh Last supper (IOI12_supper) C++
Compilation error
0 ms 0 KB
#include "advisor.h"
int late[100002],color[100002];

void ComputeAdvice(int *C, int N, int K, int M)
{
    for(int i=0;i<N;i++)color[i]=C[i],late[i]=-1;
    for(int i=0;i<N;i++)
    {
        late[color[i]]=i;
    }
    for(int i=0;i<K;i++)
    {
        if(late[i]==-1)WriteAdvice(1);
        else WriteAdvice(0);
    }
    for(int i=0;i<N;i++)
    {
        if(late[color[i]]==i)
        {
            WriteAdvice(1);
        }
        else WriteAdvice(0);
    }
}

#include "assistant.h"
int check,o,sz,go[100002],T[100002],ch[100002],p,st[100002],sz,t;
void Assist(unsigned char *A, int N, int K, int R)
{
    for(int i=0;i<N;i++)go[i]=-1;
    for(int i=0;i<K;i++)
    {
        st[i]=i;
        go[i]=i;
        if(A[i]==0)
        {
            ch[i]=0;
        }
        else
        {
            ch[i]=1;
            T[sz++]=i;
        }
    }
    for(int i=0;i<N;i++)
    {
        p=GetRequest();
        check=A[K+i];
        o=0;
        int j;
        if(go[p]!=-1)
        {
            if(check)ch[go[p]]=1,T[sz++]=go[p];
        }
        else
        {
            o=0;
            if(sz)
            {
                sz--;
                PutBack(st[T[sz]]);
                go[st[T[sz]]=-1;
                st[T[sz]]=p;
                ch[T[sz]]=check;
                go[p]=T[sz];
            }
            else
            {
                PutBack(st[0]);
                go[st[0]]=-1;
                st[0]=p;
                ch[0]=check;
                go[p]=0;
            }
        }
    }
}

Compilation message

assistant.cpp:4:61: error: redefinition of 'int sz'
 int check,o,sz,go[100002],T[100002],ch[100002],p,st[100002],sz,t;
                                                             ^~
assistant.cpp:4:13: note: 'int sz' previously declared here
 int check,o,sz,go[100002],T[100002],ch[100002],p,st[100002],sz,t;
             ^~
assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:39:32: error: expected ']' before ';' token
                 go[st[T[sz]]=-1;
                                ^
assistant.cpp:27:13: warning: unused variable 'j' [-Wunused-variable]
         int j;
             ^