Submission #789175

#TimeUsernameProblemLanguageResultExecution timeMemory
789175enerelt14The Big Prize (IOI17_prize)C++14
Compilation error
0 ms0 KiB
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <chrono> #include <climits> #include <cmath> #include <complex> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <vector> using namespace std; const int B = 472; int val; vector<int> find(int l, int r){ if (l > r)return {}; vector<int> x = ask(r); if (x[0] + x[1] != val)return find(l, r - 1) + {r}; int tl = l, tr = r; while (tl != tr){ int mid = (tl + tr) / 2; vector<int> y = ask(mid); if (y[0] + y[1] != val){ tl = mid + 1; continue; } if (y[1] != x[1])tl = mid + 1; else tr = mid; } if (l == tr)return {}; else return find(l, tr - 2) + {tr - 1}; } int find_best(int n){ vector<int> non_lolipop, x; for (int i = 0; i < B; i++){ x = ask(i); val = max(val, x[0] + x[1]); } for (int i = 0; i < n; i += B){ non_lolipop += find(i, min(n - 1, i + B - 1)); } for (int i = 0; i < non_lolipop.size(); i++){ x = ask(non_lolipop[i]); if (x[0] + x[1] == 0)return non_lolipop[i]; } }

Compilation message (stderr)

prize.cpp: In function 'std::vector<int> find(int, int)':
prize.cpp:26:18: error: 'ask' was not declared in this scope
   26 |  vector<int> x = ask(r);
      |                  ^~~
prize.cpp:27:49: error: expected primary-expression before '{' token
   27 |  if (x[0] + x[1] != val)return find(l, r - 1) + {r};
      |                                                 ^
prize.cpp:27:48: error: expected ';' before '{' token
   27 |  if (x[0] + x[1] != val)return find(l, r - 1) + {r};
      |                                                ^~
      |                                                ;
prize.cpp:27:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   27 |  if (x[0] + x[1] != val)return find(l, r - 1) + {r};
      |  ^~
prize.cpp:27:49: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   27 |  if (x[0] + x[1] != val)return find(l, r - 1) + {r};
      |                                                 ^
prize.cpp:27:51: error: expected ';' before '}' token
   27 |  if (x[0] + x[1] != val)return find(l, r - 1) + {r};
      |                                                   ^
      |                                                   ;
prize.cpp:27:50: warning: statement has no effect [-Wunused-value]
   27 |  if (x[0] + x[1] != val)return find(l, r - 1) + {r};
      |                                                  ^
prize.cpp:40:32: error: expected primary-expression before '{' token
   40 |  else return find(l, tr - 2) + {tr - 1};
      |                                ^
prize.cpp:40:31: error: expected ';' before '{' token
   40 |  else return find(l, tr - 2) + {tr - 1};
      |                               ^~
      |                               ;
prize.cpp:40:2: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
   40 |  else return find(l, tr - 2) + {tr - 1};
      |  ^~~~
prize.cpp:40:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
   40 |  else return find(l, tr - 2) + {tr - 1};
      |                                ^
prize.cpp:40:39: error: expected ';' before '}' token
   40 |  else return find(l, tr - 2) + {tr - 1};
      |                                       ^
      |                                       ;
prize.cpp:40:36: warning: statement has no effect [-Wunused-value]
   40 |  else return find(l, tr - 2) + {tr - 1};
      |                                 ~~~^~~
prize.cpp: In function 'int find_best(int)':
prize.cpp:46:7: error: 'ask' was not declared in this scope
   46 |   x = ask(i);
      |       ^~~
prize.cpp:50:15: error: no match for 'operator+=' (operand types are 'std::vector<int>' and 'std::vector<int>')
   50 |   non_lolipop += find(i, min(n - 1, i + B - 1));
      |   ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prize.cpp:52:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |  for (int i = 0; i < non_lolipop.size(); i++){
      |                  ~~^~~~~~~~~~~~~~~~~~~~
prize.cpp:53:7: error: 'ask' was not declared in this scope
   53 |   x = ask(non_lolipop[i]);
      |       ^~~
prize.cpp:44:14: warning: control reaches end of non-void function [-Wreturn-type]
   44 |  vector<int> non_lolipop, x;
      |              ^~~~~~~~~~~