이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <vector>
#include "library.h"
using namespace std;
//#include <iostream>
vector<int> res, v;
void Solve(int n)
{
for(int i = 0; i < n; i++) res.push_back(i);
v.resize(n);
int s = 0, e = n-1;
while(s < e) {
//cout << s<<' '<<e<<endl;
//for(int x : res) cout<<x<<' ';
//cout<<endl;
int lb = s, ub = e, mid;
while(lb < ub) {
mid = lb+ub>>1;
for(int i = 0; i < n; i++) v[res[i]] = (lb <= i && i <= mid);
int x = Query(v);
for(int i = s; i <= e; i++) v[res[i]] ^= 1;
int y = Query(v);
if(x >= y) ub = mid;
else lb = mid+1;
}
//cout<<res[lb]<<endl;
if(s > 0) {
for(int i = 0; i < n; i++) v[i] = (i == res[s-1] || i == res[lb]);
int x = Query(v);
if(x == 1) swap(res[s++], res[lb]);
else swap(res[e--], res[lb]);
}
else if(e < n-1) {
for(int i = 0; i < n; i++) v[i] = (i == res[e+1] || i == res[lb]);
int x = Query(v);
if(x == 1) swap(res[e--], res[lb]);
else swap(res[s++], res[lb]);
}
else swap(res[s++], res[lb]);
}
for(int &x : res) x++;
Answer(res);
}
컴파일 시 표준 에러 (stderr) 메시지
library.cpp: In function 'void Solve(int)':
library.cpp:22:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
22 | mid = lb+ub>>1;
| ~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |