Submission #933801

#TimeUsernameProblemLanguageResultExecution timeMemory
933801berrA Difficult(y) Choice (BOI21_books)C++17
Compilation error
0 ms0 KiB
long long s(int a){ if(vis[a]!=-1) return vis[a]; else return vis[a] = skim(a+1); } void ans(int left, int right, int extra){ vector<int> a; for(int i=1; i<=left; i++) a.push_back(i); for(int i=vis.size()-1; i>=vis.size()-right; i--) a.push_back(i); if(extra!=-1)a.push_back(extra+1); sort(a.begin(), a.end()); answer(a); } int get(int l, int r){ int k = l-1; long long sum=0; for(int i=0; i<l; i++) sum+=s(i); for(int i=vis.size()-2; i>vis.size()-r-1; i--) sum+=s(i); for(int j=17; j>=0; j--){ int tmp = k+(1<<j); if(tmp>=vis.size()-r-1) continue; if(s(tmp)+sum <a) k= tmp; } k++; if(k<vis.size()-1-r&&sum+s(k) <=2*a && sum+s(k) >=a){ flag = 0; ans(l, r, k); } return k; } void solve(int N, int K, long long A, int S) { vis.resize(N+1, -1LL); a = A; int v=get(K-1, 0); if(flag){ for(int i=0; i<K; i++){ s(i); } for(int i=v-1; i>=v-K; i--){ s(i); } for(int i=0; i<=K&&flag; i++){ long long sum=0; for(int l=0; l<i; l++) sum+=s(l); for(int l=v-1; l>=v-(K-i); l--) sum+=s(l); if(sum>=A&&sum<=2*A){ vector<int> a; for(int l=0; l<i; l++) a.push_back(l+1); for(int l=v-K+i; l<=v-1; l++) a.push_back(l+1); flag = 0; answer(a); } } } if(flag) impossible(); }

Compilation message (stderr)

books.cpp: In function 'long long int s(int)':
books.cpp:3:8: error: 'vis' was not declared in this scope
    3 |     if(vis[a]!=-1) return vis[a];
      |        ^~~
books.cpp:4:26: error: 'skim' was not declared in this scope
    4 |     else return vis[a] = skim(a+1);
      |                          ^~~~
books.cpp: In function 'void ans(int, int, int)':
books.cpp:8:5: error: 'vector' was not declared in this scope
    8 |     vector<int> a;
      |     ^~~~~~
books.cpp:8:12: error: expected primary-expression before 'int'
    8 |     vector<int> a;
      |            ^~~
books.cpp:9:32: error: 'a' was not declared in this scope
    9 |     for(int i=1; i<=left; i++) a.push_back(i);
      |                                ^
books.cpp:10:15: error: 'vis' was not declared in this scope
   10 |     for(int i=vis.size()-1; i>=vis.size()-right; i--) a.push_back(i);
      |               ^~~
books.cpp:10:55: error: 'a' was not declared in this scope
   10 |     for(int i=vis.size()-1; i>=vis.size()-right; i--) a.push_back(i);
      |                                                       ^
books.cpp:11:18: error: 'a' was not declared in this scope
   11 |     if(extra!=-1)a.push_back(extra+1);
      |                  ^
books.cpp:13:10: error: 'a' was not declared in this scope
   13 |     sort(a.begin(), a.end());
      |          ^
books.cpp:13:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   13 |     sort(a.begin(), a.end());
      |     ^~~~
      |     short
books.cpp:14:5: error: 'answer' was not declared in this scope
   14 |     answer(a);
      |     ^~~~~~
books.cpp: In function 'int get(int, int)':
books.cpp:20:15: error: 'vis' was not declared in this scope
   20 |     for(int i=vis.size()-2; i>vis.size()-r-1; i--) sum+=s(i);
      |               ^~~
books.cpp:24:17: error: 'vis' was not declared in this scope
   24 |         if(tmp>=vis.size()-r-1) continue;
      |                 ^~~
books.cpp:25:24: error: 'a' was not declared in this scope
   25 |         if(s(tmp)+sum <a) k= tmp;
      |                        ^
books.cpp:28:10: error: 'vis' was not declared in this scope
   28 |     if(k<vis.size()-1-r&&sum+s(k) <=2*a && sum+s(k) >=a){
      |          ^~~
books.cpp:28:39: error: 'a' was not declared in this scope
   28 |     if(k<vis.size()-1-r&&sum+s(k) <=2*a && sum+s(k) >=a){
      |                                       ^
books.cpp:29:9: error: 'flag' was not declared in this scope
   29 |         flag = 0;
      |         ^~~~
books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:37:5: error: 'vis' was not declared in this scope
   37 |     vis.resize(N+1, -1LL);
      |     ^~~
books.cpp:38:5: error: 'a' was not declared in this scope
   38 |     a = A;
      |     ^
books.cpp:40:8: error: 'flag' was not declared in this scope
   40 |     if(flag){
      |        ^~~~
books.cpp:56:17: error: 'vector' was not declared in this scope
   56 |                 vector<int> a;
      |                 ^~~~~~
books.cpp:56:24: error: expected primary-expression before 'int'
   56 |                 vector<int> a;
      |                        ^~~
books.cpp:60:17: error: 'answer' was not declared in this scope
   60 |                 answer(a);
      |                 ^~~~~~
books.cpp:67:8: error: 'flag' was not declared in this scope
   67 |     if(flag) impossible();
      |        ^~~~
books.cpp:67:14: error: 'impossible' was not declared in this scope
   67 |     if(flag) impossible();
      |              ^~~~~~~~~~