Submission #549181

#TimeUsernameProblemLanguageResultExecution timeMemory
549181esomerThe Big Prize (IOI17_prize)C++17
20 / 100
73 ms1200 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; void bin(int l, int r, int lx, int rx){ if(v.size() == mx) return; if(l == r){ nw.push_back(v[l]); return; } int mid = (l + r) / 2; vector<int> rep = ask(v[mid]); // int curr = mid; while(rep[0] + rep[1] != mx && curr > l){ nw.push_back(v[curr]); curr--; rep = ask(v[curr]); // } 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; while(rep[0] + rep[1] != mx && curr < r){ nw.push_back(v[curr]); curr++; rep = ask(v[curr]); } 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; int lst = 0; for(int i = 0; i < a[curr] && i < v.size(); i++){ vector<int> rep = ask (v[i]); // lst = i; mx = max(mx, rep[0] + rep[1]); if(rep[0] + rep[1] == 0) return v[i]; if(pow(mx, 4) > n) break; } bin(lst, v.size() - 1, 0, 0); curr++; v = nw; sort(v.begin(), v.end()); nw.clear(); t++; } for(int x : v){ 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:12:14: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   12 |  if(v.size() == mx) return;
      |     ~~~~~~~~~^~~~~
prize.cpp: In function 'int find_best(int)':
prize.cpp:47:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |   for(int i = 0; i < a[curr] && i < v.size(); i++){
      |                                 ~~^~~~~~~~~~
prize.cpp:65:1: warning: control reaches end of non-void function [-Wreturn-type]
   65 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...