답안 #18813

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
18813 2016-02-15T21:26:07 Z ggoh 최후의 만찬 (IOI12_supper) C++
0 / 100
451 ms 16312 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++;
    }
    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++;
    }
    while(p<R)
    {
        u=0;
        for(int i=0;i<t;i++)
        {
            u+=A[p+i]*(1<<i);
        }
        color[sz++]=u;
        p+=t;
    }
    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:59:23: warning: 'on' may be used uninitialized in this function [-Wmaybe-uninitialized]
                 ch[on]=0;
                 ~~~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 612 KB Output is correct
2 Correct 4 ms 776 KB Output is correct
3 Correct 6 ms 1060 KB Output is correct
4 Incorrect 12 ms 1192 KB Output isn't correct - not an optimal way
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 34 ms 2200 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 355 ms 11908 KB Output is correct
2 Incorrect 25 ms 12856 KB Error - advice is too long
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 12856 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 447 ms 14532 KB Output isn't correct - not an optimal way
2 Partially correct 387 ms 15952 KB Output is partially correct - 1700000 bits used
3 Partially correct 397 ms 16132 KB Output is partially correct - 1700000 bits used
4 Partially correct 451 ms 16312 KB Output is partially correct - 1700000 bits used
5 Partially correct 429 ms 16312 KB Output is partially correct - 1700000 bits used
6 Partially correct 409 ms 16312 KB Output is partially correct - 1700000 bits used
7 Partially correct 427 ms 16312 KB Output is partially correct - 1697263 bits used
8 Partially correct 373 ms 16312 KB Output is partially correct - 1700000 bits used
9 Partially correct 411 ms 16312 KB Output is partially correct - 1700000 bits used
10 Partially correct 435 ms 16312 KB Output is partially correct - 1700000 bits used