Submission #1012665

#TimeUsernameProblemLanguageResultExecution timeMemory
1012665hyakupThe Big Prize (IOI17_prize)C++17
98.26 / 100
41 ms1368 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; #define bug(x) cout << #x << " " << x << endl; #define pii pair<int, int> map<int, pii> mp; pii query( int id ){ if( mp.count(id) ) return mp[id]; vector<int> resp = ask(id); return (mp[id] = pii(resp[0], resp[1])); } int solve( int ini, int fim ){ if( query(ini).first + query(ini).second == 0 ) return ini; if( query(fim).first + query(fim).second == 0 ) return fim; if( query(fim).first == 0 || query(ini).second == 0 ) return -1; if( query(ini) == query(fim) ) return (( query(ini).first + query(ini).second == 0 ) ? ini : -1 ); int mid = (ini + fim)/2; if( rand()%2 ){ int aux = solve( ini, mid ); if( aux != -1 ) return aux; if( fim - ini == 1 ) return solve( fim, fim ); return solve( mid, fim ); } else{ if( fim - ini == 1 ) return solve( fim, fim ); int aux = solve( mid, fim ); if( aux != -1 ) return aux; return solve( ini, mid ); } } int find_best(int n) { srand(time(0)); return solve( 0, n - 1 ); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...