Submission #632721

# Submission time Handle Problem Language Result Execution time Memory
632721 2022-08-20T16:57:19 Z Iwanttobreakfree Last supper (IOI12_supper) C++17
Compilation error
0 ms 0 KB
#include "advisor.h"
#include <vector>
#include <set>
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M) {
    for(int i=0;i<N;i++){
        int x=C[i];
        for(int j=0;j<20;j++){
            if(x&1)WriteAdvice(1);
            else WriteAdvice(0);
            x/=2;
        }
    }
}
#include "assistant.h"
#include <vector>
#include <set>
void Assist(unsigned char *A, int N, int K, int R) {
      vector<int> V(N),cnt(N);
      set<int> S;
      set<pair<int,int>> M;
      for(int i=0;i<K;i++)S.insert(i);
      for(int i=0;i<N*20;i+=20){
        for(int j=19;j>=0;j--){
            V[i/20]*=2;
            V[i/20]+=A[i+j]-'0';
        }
      }
      vector<vector<int>> needed(N,vector<int>());
      for(int i=0;i<N;i++)needed[i].push_back(N);
      for(int i=N-1;i>=0;i++)needed[V[i]].push_back(i);
      for(int i=0;i<K;i++){
        M.insert({-needed[i].back(),i});
      }
      for(int i=0;i<N;i++)cnt[i]=needed[i].size()-1;
      for (int i = 0; i < N; i++) {
        int req = GetRequest();
        if (S.find(req)==S.end()){
            auto it=M.begin();
            S.erase(it->second);
            S.insert(req);
            PutBack(it->second);
            M.erase(it);
            cnt[req]--;
            M.insert({-needed[req][cnt[req]],req});
        }
        else{
            M.erase({-needed[req][cnt[req]],req});
            cnt[req]--;
            M.insert({-needed[req][cnt[req]],req});
        }
      }

}

Compilation message

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:5:7: error: 'vector' was not declared in this scope
    5 |       vector<int> V(N),cnt(N);
      |       ^~~~~~
assistant.cpp:5:7: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from assistant.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from assistant.cpp:2:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
assistant.cpp:5:14: error: expected primary-expression before 'int'
    5 |       vector<int> V(N),cnt(N);
      |              ^~~
assistant.cpp:6:7: error: 'set' was not declared in this scope
    6 |       set<int> S;
      |       ^~~
assistant.cpp:6:7: note: suggested alternatives:
In file included from /usr/include/c++/10/set:61,
                 from assistant.cpp:3:
/usr/include/c++/10/bits/stl_set.h:94:11: note:   'std::set'
   94 |     class set
      |           ^~~
In file included from assistant.cpp:3:
/usr/include/c++/10/set:78:13: note:   'std::pmr::set'
   78 |       using set = std::set<_Key, _Cmp, polymorphic_allocator<_Key>>;
      |             ^~~
assistant.cpp:6:11: error: expected primary-expression before 'int'
    6 |       set<int> S;
      |           ^~~
assistant.cpp:7:11: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    7 |       set<pair<int,int>> M;
      |           ^~~~
      |           std::pair
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from assistant.cpp:2:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: 'std::pair' declared here
  211 |     struct pair
      |            ^~~~
assistant.cpp:7:16: error: expected primary-expression before 'int'
    7 |       set<pair<int,int>> M;
      |                ^~~
assistant.cpp:8:27: error: 'S' was not declared in this scope
    8 |       for(int i=0;i<K;i++)S.insert(i);
      |                           ^
assistant.cpp:11:13: error: 'V' was not declared in this scope
   11 |             V[i/20]*=2;
      |             ^
assistant.cpp:15:21: error: expected primary-expression before 'int'
   15 |       vector<vector<int>> needed(N,vector<int>());
      |                     ^~~
assistant.cpp:16:27: error: 'needed' was not declared in this scope
   16 |       for(int i=0;i<N;i++)needed[i].push_back(N);
      |                           ^~~~~~
assistant.cpp:17:30: error: 'needed' was not declared in this scope
   17 |       for(int i=N-1;i>=0;i++)needed[V[i]].push_back(i);
      |                              ^~~~~~
assistant.cpp:17:37: error: 'V' was not declared in this scope
   17 |       for(int i=N-1;i>=0;i++)needed[V[i]].push_back(i);
      |                                     ^
assistant.cpp:19:9: error: 'M' was not declared in this scope
   19 |         M.insert({-needed[i].back(),i});
      |         ^
assistant.cpp:19:20: error: 'needed' was not declared in this scope
   19 |         M.insert({-needed[i].back(),i});
      |                    ^~~~~~
assistant.cpp:21:27: error: 'cnt' was not declared in this scope; did you mean 'int'?
   21 |       for(int i=0;i<N;i++)cnt[i]=needed[i].size()-1;
      |                           ^~~
      |                           int
assistant.cpp:21:34: error: 'needed' was not declared in this scope
   21 |       for(int i=0;i<N;i++)cnt[i]=needed[i].size()-1;
      |                                  ^~~~~~
assistant.cpp:24:13: error: 'S' was not declared in this scope
   24 |         if (S.find(req)==S.end()){
      |             ^
assistant.cpp:25:21: error: 'M' was not declared in this scope
   25 |             auto it=M.begin();
      |                     ^
assistant.cpp:30:13: error: 'cnt' was not declared in this scope; did you mean 'int'?
   30 |             cnt[req]--;
      |             ^~~
      |             int
assistant.cpp:31:24: error: 'needed' was not declared in this scope
   31 |             M.insert({-needed[req][cnt[req]],req});
      |                        ^~~~~~
assistant.cpp:34:13: error: 'M' was not declared in this scope
   34 |             M.erase({-needed[req][cnt[req]],req});
      |             ^
assistant.cpp:34:23: error: 'needed' was not declared in this scope
   34 |             M.erase({-needed[req][cnt[req]],req});
      |                       ^~~~~~
assistant.cpp:34:35: error: 'cnt' was not declared in this scope; did you mean 'int'?
   34 |             M.erase({-needed[req][cnt[req]],req});
      |                                   ^~~
      |                                   int