이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "minerals.h"
#include<bits/stdc++.h>
using namespace std;
set<int>st;
int query(int k){
if(st.count(k))
st.erase(k);
else st.insert(k);
return Query(k);
}
mt19937 rng(random_device{}());
void solve(vector<int>A,vector<int>B,int dep){
if(A.size()==1) return Answer(A[0],B[0]);
vector<int>A1,A2;
vector<int>B1,B2;
int CC=0;
for(auto i:A)
(CC++%3?A2:A1).push_back(i);
int prv=0;
for(auto i:A1)
prv=query(i);
shuffle(B.begin(),B.end(),rng);
for(auto i:B) {
if(A1.size()==B1.size()){
B2.push_back(i);
continue;
} else if(A2.size()==B2.size()){
B1.push_back(i);
continue;
}
int x=query(i);
if(st.count(A1[0])^(x==prv))
B2.push_back(i);
else B1.push_back(i);
prv=x;
}
solve(A1,B1,dep^1);
solve(A2,B2,dep^1);
}
void Solve(int N) {
vector<int>A,B;
int prv=0;
vector<int>VV(2*N);
iota(VV.begin(),VV.end(),1);
shuffle(VV.begin(),VV.end(),rng);
for(auto i:VV) {
if(A.size()==N){
B.push_back(i);
continue;
} else if(B.size()==N){
A.push_back(i);
continue;
}
if(query(i)!=prv)
A.push_back(i),prv++;
else B.push_back(i);
}
solve(A,B,0);
}
컴파일 시 표준 에러 (stderr) 메시지
minerals.cpp: In function 'void Solve(int)':
minerals.cpp:47:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
47 | if(A.size()==N){
| ~~~~~~~~^~~
minerals.cpp:50:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
50 | } else if(B.size()==N){
| ~~~~~~~~^~~
# | 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... |
# | 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... |