이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "chameleon.h"
#include <bits/stdc++.h>
//#include "grader.cpp"
using namespace std;
namespace {
int variable_example = 1;
int n;
} // namespace
bool find(int x,int y){
vector<int> g;
for(int i=1;i<=n;i++){
if(i==x || i==y){
continue;
}
g.push_back(i);
}
int z=Query(g);
return z==(n/2-1);
}
mt19937 rnd(time(NULL));
void Solve(int N) {
n=2*N;
vector<int> tt(n);
iota(tt.begin(),tt.end(),1);
while(tt.size()>2){
shuffle(tt.begin(),tt.end(),rnd);
vector<int> s,t;
for(auto h:tt){
if(!s.size()){
s.push_back(h);
continue;
}
s.push_back(h);
if(Query(s)==s.size()){
continue;
}
s.pop_back();
cerr << h << "\n";
int l=0,r=((int)s.size())-1;
while(r>l){
int m=(l+r)/2;
vector<int> tmp;
for(int i=0;i<=m;i++){
tmp.push_back(s[i]);
}
tmp.push_back(h);
if(Query(tmp)<=(int)tmp.size()-1){
r=m;
}
else{
l=m+1;
}
}
cerr << s[l] << " " << h << "\n";
if(find(s[l],h)){
Answer(s[l],h);
swap(s[l],s.back());
s.pop_back();
}
else{
t.push_back(h);
}
}
s.insert(s.end(),t.begin(),t.end());
tt.swap(s);
}
if(tt.size()){
Answer(tt[0],tt[1]);
}
}
컴파일 시 표준 에러 (stderr) 메시지
chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:37:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | if(Query(s)==s.size()){
| ~~~~~~~~^~~~~~~~~~
chameleon.cpp: At global scope:
chameleon.cpp:8:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
8 | int variable_example = 1;
| ^~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |