Submission #51015

#TimeUsernameProblemLanguageResultExecution timeMemory
51015FLDutchmanThe Big Prize (IOI17_prize)C++14
0 / 100
2 ms376 KiB
#include <bits/stdc++.h> //#include "grader.cpp" #include "prize.h" using namespace std; #define mp make_pair #define pb push_back const int INF = 1000000000; typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<vi> vvi; typedef long double num; typedef pair<num, num> nn; typedef vector<nn> vnn; typedef vector<num> vn; typedef vector<vn> vvn; vii answers; int maxVal = 0; int N; ii query(int i){ if(answers[i] != mp(-1, -1)) return answers[i]; vi a = ask(i); return answers[i] = mp(a[0], a[1]); } void genQueries(){ // do 711 queries in the shape of a bs queue<ii> bounds; bounds.push(mp(-1, N)); int queriesLeft = 711; while(queriesLeft --){ ii q = bounds.front(); bounds.pop(); int mb = (q.first+q.second)/2; query(mb); maxVal = max(maxVal, answers[mb].first + answers[mb].second); bounds.push(mp(q.first, mb)); bounds.push(mp(mb, q.second)); } } int find_best(int n){ N = n; int betterFound = 0; int lb = -1; while(betterFound < maxVal){ int rb = n; while(lb + 1 != rb){ int mb = (lb + rb)/2; ii ans = query(mb); if(ans.second < maxVal - betterFound){ rb = mb; } else { lb = mb; } } betterFound++; lb++; } for(int i = 0; i < answers.size(); i++){ if(answers[i] == mp(0, 0)) return i; } }

Compilation message (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:66:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < answers.size(); i++){
                    ~~^~~~~~~~~~~~~~~~
prize.cpp:70:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...