제출 #642076

#제출 시각아이디문제언어결과실행 시간메모리
642076piOOE커다란 상품 (IOI17_prize)C++17
90 / 100
83 ms1188 KiB
#include <bits/stdc++.h> #include "prize.h" using namespace std; using ll = long long; int find_best(int n) { int i = 0; int logn = __lg(n) + 2; map<int, vector<int>> mp; int Q = 0; auto my_ask = [&](int i) { if (mp.count(i)) { return mp[i]; } else { ++Q; if (Q > 10000) { assert(false); } mp[i] = ask(i); return mp[i]; } }; map<int, int> cnt; for (; i < n;) { auto a = my_ask(i); int sum = a[0] + a[1]; if (sum == 0) { return i; } else { ++cnt[sum]; if (cnt[sum] >= 500) { for (int j = __lg(n) + 1; j > -1; --j) { if (i + (1 << j) < n && my_ask(i + (1 << j)) == a) { i += 1 << j; } } ++i; } else { i += 1; } } } assert(false); }

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

prize.cpp: In function 'int find_best(int)':
prize.cpp:9:9: warning: unused variable 'logn' [-Wunused-variable]
    9 |     int logn = __lg(n) + 2;
      |         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...