Submission #137815

#TimeUsernameProblemLanguageResultExecution timeMemory
137815MAMBAThe Big Prize (IOI17_prize)C++17
Compilation error
0 ms0 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; #define rep(i , j , k) for(int i = j; i < (int)k; i++) #define all(x) x.begin(),x.end() typedef vector<int> vi; map<int , vi> mp; inline vi F(int i) { if (mp.count(i)) return mp[i]; if (mp.size() + 1 > 10000) assert(0); return (mp[i] = ask(i)); } inline int sum(vi me) { return accumulate(all(me) , 0); } int least, ans; bitset<400000> mark; void solve(int l , int r, int le , int ri) { if (ans != -1) return; if (l >= r) return; if (le + ri == least) return; int mid = l + r >> 1; bool happy = false; rep(i , 0 , r - l) { if (i & 1) mid -= i; else mid += i; vi me = F(mid); mark[mid] = true; if (sum(me) == 0) { ans = mid; return; } if (sum(me) == least) { happy = true; break; } if (le + ri + i + 1 == least) return; } if (!happy) return; int ptr = l; while (!mark[ptr]) ptr++; int ptr2 = ptr; while (sum(F(ptr2)) != least) ptr2++; int ptr3 = r - 1; while (!mark[ptr3]) ptr3--; int ptr4 = ptr3; while (sum(F(ptr4)) != least) ptr4--; solve(l , ptr , le , ptr2 - ptr + F(ptr2)[1]); solve(ptr3 + 1 , r , ptr3 - ptr4 + F(ptr4)[0], ri); } int find_best(int n) { mp.clear(); rep(i , 0 , n) mark[i] = false; least = -1; ans = -1; for (int i = 0 , i < min(n , 50); i++) { least = max(least , sum(F(i1))); if (sum(F(i)) == 0) return i; } solve(0 , n , 0 , 0); return ans; }

Compilation message (stderr)

prize.cpp: In function 'void solve(int, int, int, int)':
prize.cpp:30:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  int mid = l + r >> 1;
            ~~^~~
prize.cpp: In function 'int find_best(int)':
prize.cpp:75:21: error: expected ';' before '<' token
  for (int i = 0 , i < min(n , 50); i++) {
                     ^
prize.cpp:75:21: error: expected primary-expression before '<' token
prize.cpp:76:29: error: 'i1' was not declared in this scope
   least = max(least , sum(F(i1)));
                             ^~
prize.cpp:76:29: note: suggested alternative: 'i'
   least = max(least , sum(F(i1)));
                             ^~
                             i