답안 #18811

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
18811 2016-02-15T21:20:08 Z ggoh 최후의 만찬 (IOI12_supper) C++
0 / 100
509 ms 24760 KB
#include "advisor.h"

void ComputeAdvice(int *C, int N, int K, int M)
{
    int t=0,u=N,p;
    u--;
    while(u)
    {
        u/=2;t++;
    }
    if(N==1)t=1;
    for(int i=0;i<N;i++)
    {
        u=C[i];
        p=t;
        while(p)
        {
            WriteAdvice(u%2);
            p--;
            u/=2;
        }
    }
}



#include "assistant.h"
int ch[100002],late[100002],st[100002],color[100002];
void Assist(unsigned char *A, int N, int K, int R)
{
    int t=0,u=N,sz=0,p=0,on;
    u--;
    while(u)
    {
        u/=2;t++;
    }
    if(N==1)t=1;
    while(p<R)
    {
        u=0;
        for(int i=0;i<t;i++)
        {
            u+=A[p+i]*(1<<i);
        }
        color[sz++]=u;
    }
    for(int i=0;i<N;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;
        if(late[i]==-1)st[t++]=i;
    }
    for(int i=0;i<N;i++)
    {
        if(ch[color[i]]==1)
        {
            GetRequest();
            if(late[color[i]]==i)
            {
                late[color[i]]=-1;
                st[t++]=color[i];
            }
        }
        else
        {
            GetRequest();
            if(t)
            {
                t--;
                PutBack(st[t]);
                ch[st[t]]=0;
                ch[color[i]]=1;
                on=color[i];
            }
            else
            {
                PutBack(on);
                ch[on]=0;
                on=color[i];
                ch[on]=1;
            }
            if(late[color[i]]==i)
            {
                late[color[i]]=-1;
                st[t++]=color[i];
            }
        }
    }
}

Compilation message

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:58:23: warning: 'on' may be used uninitialized in this function [-Wmaybe-uninitialized]
                 ch[on]=0;
                 ~~~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 3808 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 51 ms 7764 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 336 ms 17412 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 20848 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 433 ms 22384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 509 ms 24148 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 410 ms 24568 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 416 ms 24760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 388 ms 24760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 411 ms 24760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 382 ms 24760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 374 ms 24760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 408 ms 24760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 408 ms 24760 KB Execution killed with signal 11 (could be triggered by violating memory limits)