Submission #549268

#TimeUsernameProblemLanguageResultExecution timeMemory
549268esomerThe Big Prize (IOI17_prize)C++17
20 / 100
43 ms1300 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; while(v.size() > 1){ mx = 0; map<int, vector<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]); int m = max(0, mx - 30); long long int sum = m * m; sum *= sum; lst = i + 1; mp[rep[0] + rep[1]].push_back(v[i]); if(rep[0] + rep[1] == 0) return v[i]; if(sum >= n) break; } int total = 0; for(auto p : mp){ if(p.first == mx) continue; total += p.second.size(); for(int x : p.second) nw.push_back(x); } bin(lst, v.size() - 1, total, 0); curr++; v = nw; sort(v.begin(), v.end()); nw.clear(); } return v[0]; }

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++){
      |                                 ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...