Submission #988834

# Submission time Handle Problem Language Result Execution time Memory
988834 2024-05-26T12:31:16 Z lalig777 Last supper (IOI12_supper) C++14
Compilation error
0 ms 0 KB
void ComputeAdvice(int *C, int N, int K, int M){
    int digits;
    for (int i=0; i<21; i++){
        if ((1<<i)>=N-1){
            digits=i;
            break;
        }
    }
    if (K==1) return;
    unordered_set<int>current;
    priority_queue<pair<int,int>>next;
    vector<queue<int>>orden(N);
    for (int i=0; i<N; i++){
        int x=C[i];
        if (x<K){
            if (!(current.find(x)!=current.end())){
                next.push(make_pair(i, x));
                current.insert(x);
            }
        }orden[x].push(i);
    }for (int i=0; i<K; i++){
        if (!(current.find(i)!=current.end())){
            next.push(make_pair(1e9, i));
            current.insert(i);
        }
    }
    for (int i=0; i<N; i++){
        int x=C[i];
        orden[x].pop();
        int pos;
        if (orden[x].empty()) pos=1e9;
        else pos=orden[x].front();
        if (!(current.find(x)!=current.end())){
            current.insert(x);
            int remov=next.top().second;
            next.pop();
            current.erase(remov);
            for (int j=digits-1; j>=0; j--){
                int y=1<<j;
                if (remov>=y){
                    remov-=y;
                    WriteAdvice('1');
                }else WriteAdvice('0');
            }
        }
        next.push(make_pair(pos, x));
    }return;
}
void Assist(unsigned char *A, int N, int K, int R){
    if (K==1){
        int now=0;
        for (int i=0; i<N; i++){
            int follow=GetRequest();
            if (follow!=now){
                PutBack(now);
                now=follow;
            }
        }return;
    }
    int digits, count=0;
    for (int i=0; i<21; i++){
        if ((1<<i)>=N){
            digits=i;
            break;
        }
    }
    unordered_set<int>current;
    for (int i=0; i<K; i++) current.insert(i);
    for (int i=0; i<N; i++){
        int follow=GetRequest();
        if (!(current.find(follow)!=current.end())){
            int remov=0;
            for (int j=0; j<digits; j++){
                if (A[j+count*digits]=='1') remov+=(1<<(digits-j-1));
            }count++;
            PutBack(remov);
            current.erase(remov);
            current.insert(follow);
        }
    }
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:10:5: error: 'unordered_set' was not declared in this scope
   10 |     unordered_set<int>current;
      |     ^~~~~~~~~~~~~
advisor.cpp:10:19: error: expected primary-expression before 'int'
   10 |     unordered_set<int>current;
      |                   ^~~
advisor.cpp:11:5: error: 'priority_queue' was not declared in this scope
   11 |     priority_queue<pair<int,int>>next;
      |     ^~~~~~~~~~~~~~
advisor.cpp:11:20: error: 'pair' was not declared in this scope
   11 |     priority_queue<pair<int,int>>next;
      |                    ^~~~
advisor.cpp:11:25: error: expected primary-expression before 'int'
   11 |     priority_queue<pair<int,int>>next;
      |                         ^~~
advisor.cpp:12:5: error: 'vector' was not declared in this scope
   12 |     vector<queue<int>>orden(N);
      |     ^~~~~~
advisor.cpp:12:12: error: 'queue' was not declared in this scope
   12 |     vector<queue<int>>orden(N);
      |            ^~~~~
advisor.cpp:12:18: error: expected primary-expression before 'int'
   12 |     vector<queue<int>>orden(N);
      |                  ^~~
advisor.cpp:16:19: error: 'current' was not declared in this scope
   16 |             if (!(current.find(x)!=current.end())){
      |                   ^~~~~~~
advisor.cpp:17:17: error: 'next' was not declared in this scope
   17 |                 next.push(make_pair(i, x));
      |                 ^~~~
advisor.cpp:17:27: error: 'make_pair' was not declared in this scope
   17 |                 next.push(make_pair(i, x));
      |                           ^~~~~~~~~
advisor.cpp:20:10: error: 'orden' was not declared in this scope
   20 |         }orden[x].push(i);
      |          ^~~~~
advisor.cpp:22:15: error: 'current' was not declared in this scope
   22 |         if (!(current.find(i)!=current.end())){
      |               ^~~~~~~
advisor.cpp:23:13: error: 'next' was not declared in this scope
   23 |             next.push(make_pair(1e9, i));
      |             ^~~~
advisor.cpp:23:23: error: 'make_pair' was not declared in this scope
   23 |             next.push(make_pair(1e9, i));
      |                       ^~~~~~~~~
advisor.cpp:29:9: error: 'orden' was not declared in this scope
   29 |         orden[x].pop();
      |         ^~~~~
advisor.cpp:33:15: error: 'current' was not declared in this scope
   33 |         if (!(current.find(x)!=current.end())){
      |               ^~~~~~~
advisor.cpp:35:23: error: 'next' was not declared in this scope
   35 |             int remov=next.top().second;
      |                       ^~~~
advisor.cpp:42:21: error: 'WriteAdvice' was not declared in this scope; did you mean 'ComputeAdvice'?
   42 |                     WriteAdvice('1');
      |                     ^~~~~~~~~~~
      |                     ComputeAdvice
advisor.cpp:43:23: error: 'WriteAdvice' was not declared in this scope; did you mean 'ComputeAdvice'?
   43 |                 }else WriteAdvice('0');
      |                       ^~~~~~~~~~~
      |                       ComputeAdvice
advisor.cpp:46:9: error: 'next' was not declared in this scope
   46 |         next.push(make_pair(pos, x));
      |         ^~~~
advisor.cpp:46:19: error: 'make_pair' was not declared in this scope
   46 |         next.push(make_pair(pos, x));
      |                   ^~~~~~~~~

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:5:24: error: 'GetRequest' was not declared in this scope
    5 |             int follow=GetRequest();
      |                        ^~~~~~~~~~
assistant.cpp:7:17: error: 'PutBack' was not declared in this scope
    7 |                 PutBack(now);
      |                 ^~~~~~~
assistant.cpp:19:5: error: 'unordered_set' was not declared in this scope
   19 |     unordered_set<int>current;
      |     ^~~~~~~~~~~~~
assistant.cpp:19:19: error: expected primary-expression before 'int'
   19 |     unordered_set<int>current;
      |                   ^~~
assistant.cpp:20:29: error: 'current' was not declared in this scope
   20 |     for (int i=0; i<K; i++) current.insert(i);
      |                             ^~~~~~~
assistant.cpp:22:20: error: 'GetRequest' was not declared in this scope
   22 |         int follow=GetRequest();
      |                    ^~~~~~~~~~
assistant.cpp:23:15: error: 'current' was not declared in this scope
   23 |         if (!(current.find(follow)!=current.end())){
      |               ^~~~~~~
assistant.cpp:28:13: error: 'PutBack' was not declared in this scope
   28 |             PutBack(remov);
      |             ^~~~~~~