Submission #549270

#TimeUsernameProblemLanguageResultExecution timeMemory
549270esomerThe Big Prize (IOI17_prize)C++17
90 / 100
75 ms1524 KiB
#include "prize.h" #include<bits/stdc++.h> using namespace std; vector<int> v; vector<int> nw; int a[] = {475, 27, 5, 1}; int mx; set<int> s; int ans = -1; void bin(int l, int r, int lx, int rx){ if(ans != -1) return; if(nw.size() == mx) return; if(l == r){ nw.push_back(v[l]); return; } int mid = (l + r) / 2; vector<int> rep = ask(v[mid]); // s.insert(v[mid]); if(rep[0] + rep[1] == 0){ ans = v[mid]; return; } int curr = mid; while(rep[0] + rep[1] != mx && curr > l){ nw.push_back(v[curr]); curr--; rep = ask(v[curr]); // s.insert(v[curr]); if(rep[0] + rep[1] == 0){ ans = v[curr]; return; } } if(rep[0] + rep[1] != mx) nw.push_back(v[curr]); if(lx + rep[1] < mx && l < curr) bin(l, curr - 1, lx, rep[1]); curr = mid + 1; rep = ask(v[curr]); s.insert(v[curr]); if(rep[0] + rep[1] == 0){ ans = v[curr]; return; } while(rep[0] + rep[1] != mx && curr < r){ nw.push_back(v[curr]); curr++; rep = ask(v[curr]); // s.insert(v[curr]); if(rep[0] + rep[1] == 0){ ans = v[curr]; return; } } if(rep[0] + rep[1] != mx) nw.push_back(v[curr]); if(rx + rep[0] < mx && r > curr) bin(mid + 1, r, rep[0], rx); } int find_best(int n) { v.resize(n); for(int i = 0; i < n; i++){ v[i] = i; } int curr = 0; int t = 0; while(v.size() > 1 && t < 1){ mx = 0; map<int, int> mp; int lst = 0; for(int i = 0; i < a[curr] && i < v.size(); i++){ vector<int> rep = ask (v[i]); // mx = max(mx, rep[0] + rep[1]); mp[rep[0] + rep[1]]++; int m = max(0, mx - 30); long long int sum = m * m; sum *= sum; lst = i + 1; if(rep[0] + rep[1] == 0) return v[i]; if(sum >= n) break; } int total = 0; for(auto p : mp){ if(p.first == mx) break; total += p.second; } bin(lst, v.size() - 1, total, 0); if(ans != -1) return ans; curr++; v = nw; sort(v.begin(), v.end()); nw.clear(); t++; } for(int x : v){ if(s.count(x)) continue; else{ vector<int> rep = ask(x); if(rep[0] + rep[1] == 0) return x; } } }

Compilation message (stderr)

prize.cpp: In function 'void bin(int, int, int, int)':
prize.cpp:15:15: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   15 |  if(nw.size() == mx) return;
      |     ~~~~~~~~~~^~~~~
prize.cpp: In function 'int find_best(int)':
prize.cpp:72:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |   for(int i = 0; i < a[curr] && i < v.size(); i++){
      |                                 ~~^~~~~~~~~~
prize.cpp:103:1: warning: control reaches end of non-void function [-Wreturn-type]
  103 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...