이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int>vi;
typedef pair<int,int>pi;
typedef vector<pi> vpi;
#define pb push_back
#define all(x) x.begin(),x.end()
//#include "grader.cpp"
int find_best(int n) {
int sz=450;
vi prv={-1,-1};
vpi segs;
for(int i=0; i<n; i+=sz){
vi s=(prv[0]==-1?ask(i):prv),e=ask(min(n-1,i+sz));
if(s[0]==0 && s[1]==0)
return i;
if(e[0]==0 && e[1]==0)
return min(i+sz,n-1);
if(e[0]==s[0])
continue;
segs.pb({i,min(i+sz,n-1)});
prv=e;
}
srand(time(0));
random_shuffle(all(segs));
vector<bool>vis(2e5);
for(pi p:segs){
int l=p.first,r=p.second;
for(int i=l+1; i<r; i++){
if(vis[i])
continue;
vi v=ask(i);
if(v==vi(2,0))
return i;
for(int j=i; j<vis.size() && !vis[j] && v[1]==0; j++)
vis[j]=1;
for(int j=i;0<=j && !vis[j] && v[0]==0; j--)
vis[j]=1;
}
}
assert(0);
return -1;
}
컴파일 시 표준 에러 (stderr) 메시지
prize.cpp: In function 'int find_best(int)':
prize.cpp:39:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | for(int j=i; j<vis.size() && !vis[j] && v[1]==0; j++)
| ~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |