이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "prize.h"
#define wiwihorz
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma loop-opt(on)
#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define rrep(i, a, b) for(int i = b; i >= a; i--)
#define all(x) x.begin(), x.end()
#define ceil(a, b) ((a + b - 1) / (b))
using namespace std;
#define pii pair<int, int>
#ifdef wiwihorz
#define print(a...) cerr << "Line: " << __LINE__, kout("[" + string(#a) + "] = ", a)
void vprint(auto L, auto R) { while(L < R)cerr << *L << " \n"[next(L) == R], ++L; }
void kout() { cerr << endl; }
template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...);}
#else
#define print(...) 0
#define vprint(...) 0
#endif
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())
int x;
map<int, pii> mp;
pii Ask(int x) {
if(mp.find(x) == mp.end()) {
vector<int> v;
v = ask(x);
mp[x] = {v[0], v[1]};
}
return mp[x];
}
int solve(int L, int R, int tot, int pre) {
// print(L, R, tot, pre);
if(L == R) {
pii p = Ask(L);
return (p.first + p.second ? -1 : L);
}
int mid = (L + R) / 2, piv = -1, ans = -1;
rep(i, mid + 1, R) {
pii p = Ask(i);
if(p.first + p.second == x) {
piv = i;
break;
}
else ans = max(ans, solve(i, i, 1, 0));
}
if(piv < 0) ans = (tot - (R - mid) ? max(ans, solve(L, mid, tot - (R - mid), pre)) : ans);
else {
pii p = Ask(piv);
int left = p.first - pre - (piv - mid - 1);
int right = tot - p.first + pre;
if(left) ans = max(ans, solve(L, mid, left, pre));
if(right) ans = max(ans, solve(piv, R, right, p.first));
}
return ans;
}
int find_best(int n) {
x = 0;
vector<int> s, s1;
rrep(i, 0, n - 1) s.push_back(i);
rep(i, 0, min(249, n) - 1) {
pii p = Ask(s[i]);
x = max(x, p.first + p.second);
}
return solve(0, n - 1, x, 0);
}
컴파일 시 표준 에러 (stderr) 메시지
prize.cpp:5: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
5 | #pragma loop-opt(on)
|
prize.cpp:15:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
15 | void vprint(auto L, auto R) { while(L < R)cerr << *L << " \n"[next(L) == R], ++L; }
| ^~~~
prize.cpp:15:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
15 | void vprint(auto L, auto R) { while(L < R)cerr << *L << " \n"[next(L) == R], ++L; }
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |