제출 #98442

#제출 시각아이디문제언어결과실행 시간메모리
98442bogdan10bos커다란 상품 (IOI17_prize)C++14
20 / 100
94 ms1176 KiB
#include <bits/stdc++.h> #include "prize.h" using namespace std; typedef pair<int, int> pii; int sq, mxcnt, ans; map<int, int> mp[2]; pii myask(int pos) { if(mp[0].count(pos)) return {mp[0][pos], mp[1][pos]}; auto v = ask(pos); mp[0][pos] = v[0]; mp[1][pos] = v[1]; return {v[0], v[1]}; } void solve(int st, int dr) { if(st > dr) return; if(ans != -1) return; auto askst = myask(st); auto askdr = myask(dr); int sumst = askst.first + askst.second; int sumdr = askdr.first + askdr.second; if(sumst == 0) { ans = st; return; } if(sumdr == 0) { ans = dr; return; } if(askst.second == 0 || askdr.first == 0) return; if(dr - st <= 1) return; if(sumst != mxcnt) { solve(st + 1, dr); return; } if(sumdr != mxcnt) { solve(st, dr - 1); return; } int cnt = askdr.first - askst.first; if(cnt == 0) return; int lgt = dr - st - 1; int mij = st + (dr - st) / 2; solve(st, mij); solve(mij, dr); } int find_best(int N) { ans = -1; sq = sqrt(N) + 1; sq = min(sq, N); mxcnt = 0; mt19937 g(chrono::high_resolution_clock::now().time_since_epoch().count()); uniform_int_distribution<int> uid(0, N - 1); for(int i = 0; i < sq && i < 300; i++) { int pos = uid(g); auto x = myask(pos); int sum = x.first + x.second; if(sum == 0) ans = pos; mxcnt = max(mxcnt, sum); } int st = 0, dr = sq; for(; st < N; ) { solve(st, dr); st += sq; dr += sq; if(dr >= N) dr = N - 1; } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

prize.cpp: In function 'void solve(int, int)':
prize.cpp:55:9: warning: unused variable 'lgt' [-Wunused-variable]
     int lgt = dr - st - 1;
         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...