제출 #1161897

#제출 시각아이디문제언어결과실행 시간메모리
1161897gelastropod커다란 상품 (IOI17_prize)C++20
20 / 100
116 ms2448 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; int find_best(int n) { // 5 types! vector<pair<int, int>> cache(n, { -1, -1 }); set<int> found; int lolpop = 0; for (int i = n - 1; i >= n - min(n, 474); i--) { auto j = ask(i); cache[i] = { j[0], j[1] }; lolpop = max(lolpop, j[0] + j[1]); if (j[0] + j[1] == 0) return i; found.insert(i); } int crnt = n - 1; while (crnt >= 0) { auto qry = cache[crnt]; if (qry.first == -1) { found.insert(crnt); auto j = ask(crnt); qry = { j[0], j[1] }; cache[crnt] = qry; } if (qry.first + qry.second == 0) return crnt; if (qry.first + qry.second == lolpop) break; crnt--; } while (crnt >= 0) { auto crntval = cache[crnt]; if (crntval.first == -1) { found.insert(crnt); auto j = ask(crnt); crntval = { j[0], j[1] }; cache[crnt] = crntval; } int low = 0, high = crnt, ans = crnt; for (int i : found) { if (cache[i].second == crntval.second) { high = min(high, i); } if (i <= crnt && cache[i].second != crntval.second) { low = max(low, i); } } while (low <= high) { int x = (low + high) / 2; pair<int, int> qry = cache[x]; if (qry.first == -1) { found.insert(x); auto j = ask(x); qry = { j[0], j[1] }; cache[x] = qry; } if (qry.second != crntval.second) { high = x - 1; } else { low = x + 1; ans = x; } } crnt = ans - 1; while (crnt >= 0) { auto qry = cache[crnt]; if (qry.first == -1) { found.insert(crnt); auto j = ask(crnt); qry = { j[0], j[1] }; cache[crnt] = qry; } if (qry.first + qry.second == 0) return crnt; if (qry.first + qry.second == lolpop) break; crnt--; } } }

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

prize.cpp: In function 'int find_best(int)':
prize.cpp:78:1: warning: control reaches end of non-void function [-Wreturn-type]
   78 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...