Submission #632706

#TimeUsernameProblemLanguageResultExecution timeMemory
632706IwanttobreakfreeLast supper (IOI12_supper)C++17
Compilation error
0 ms0 KiB
//#include "assistant.h" #include "advisor.h" #include <vector> #include <set> void ComputeAdvice(int *C, int N, int K, int M) { for(int i=0;i<N;i++){ for(int j=0;j<20;j++){ if(C[i]&1)WriteAdvice(1); else WriteAdvice(0); C[i]/=2; } } } /*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;i+=20){ for(int j=0;j<20;j++){ V[i]*=2; V[i]+=A[i]; } } vector<vector<int>> needed(N); 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[0][0],i}); } for (i = 0; i < N; i++) { int req = GetRequest(); if (S.find(req)==S.end()){ auto it=M.begin(); 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}); } } }*/
#include "assistant.h" //#include "advisor.h" #include <vector> #include <set> /*void ComputeAdvice(int *C, int N, int K, int M) { for(int i=0;i<N;i++){ for(int j=0;j<20;j++){ if(C[i]&1)WriteAdvice(1); else WriteAdvice(0); C[i]/=2; } } }*/ 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;i+=20){ for(int j=0;j<20;j++){ V[i]*=2; V[i]+=A[i]; } } vector<vector<int>> needed(N); 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[0][0],i}); } for (i = 0; i < N; i++) { int req = GetRequest(); if (S.find(req)==S.end()){ auto it=M.begin(); 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 (stderr)

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