#include "minerals.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long int lld;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define trav(a,v) for(auto a:v)
int n;
set<int> s;
int last_answer;
void clear(){
trav(a,s){
Query(a);
}
}
vector<pair<int,int> >Answers;
int Query2(int x){
//cout<<x<<endl;
last_answer=Query(x);
if(s.find(x)==s.end()){
s.insert(x);
}else s.erase(x);
return last_answer;
}
void Work(vector<int> v1,vector<int> v2){
/*if(v1.size()!=0){
rep(i,0,v1.size()){
cout<<v1[i]<<" ";
}cout<<endl;
}*/
if(v1.size()==1){
Answers.push_back(pair<int,int>(v1[0],v2[0]));
return;
}
vector<int> v11,v12,v21,v22;
rep(i,0,(int)v1.size()){
if(2*i<(int)v1.size()){
v11.push_back(v1[i]);
if(s.find(v1[i])==s.end()){
Query2(v1[i]);
}
}else{
v12.push_back(v1[i]);
if(s.find(v1[i])!=s.end()){
Query2(v1[i]);
}
}
}
int LST=last_answer;
rep(i,0,(int)v2.size()){
if(Query2(v2[i])==LST){
v21.push_back(v2[i]);
}else{
v22.push_back(v2[i]);
}
LST=last_answer;
}
Work(v11,v21);
Work(v12,v22);
}
void Solve(int N) {
n=N;
int Q=0;
vector<int> v1,v2;
last_answer=0;
rep(i,1,2*n+1){
if(Query2(i)==Q){
Query2(i);
v2.push_back(i);
}else{
Q++;
s.insert(i);
v1.push_back(i);
}
}//cout<<Q<<endl;
Work(v1,v2);
rep(i,0,(int)Answers.size()){
//cout<<Answers[i].first<<" "<<Answers[i].second<<endl;
Answer(Answers[i].first,Answers[i].second);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
252 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
376 KB |
Output is correct |
2 |
Correct |
13 ms |
632 KB |
Output is correct |
3 |
Correct |
24 ms |
916 KB |
Output is correct |
4 |
Correct |
66 ms |
1448 KB |
Output is correct |
5 |
Correct |
115 ms |
2516 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
252 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
6 ms |
376 KB |
Output is correct |
6 |
Correct |
13 ms |
632 KB |
Output is correct |
7 |
Correct |
24 ms |
916 KB |
Output is correct |
8 |
Correct |
66 ms |
1448 KB |
Output is correct |
9 |
Correct |
115 ms |
2516 KB |
Output is correct |
10 |
Correct |
6 ms |
420 KB |
Output is correct |
11 |
Correct |
77 ms |
1780 KB |
Output is correct |
12 |
Correct |
111 ms |
2424 KB |
Output is correct |
13 |
Correct |
92 ms |
2212 KB |
Output is correct |
14 |
Correct |
90 ms |
2152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
252 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
6 ms |
376 KB |
Output is correct |
6 |
Correct |
13 ms |
632 KB |
Output is correct |
7 |
Correct |
24 ms |
916 KB |
Output is correct |
8 |
Correct |
66 ms |
1448 KB |
Output is correct |
9 |
Correct |
115 ms |
2516 KB |
Output is correct |
10 |
Correct |
6 ms |
420 KB |
Output is correct |
11 |
Correct |
77 ms |
1780 KB |
Output is correct |
12 |
Correct |
111 ms |
2424 KB |
Output is correct |
13 |
Correct |
92 ms |
2212 KB |
Output is correct |
14 |
Correct |
90 ms |
2152 KB |
Output is correct |
15 |
Correct |
451 ms |
5748 KB |
Output is correct |
16 |
Correct |
421 ms |
5884 KB |
Output is correct |
17 |
Correct |
275 ms |
5660 KB |
Output is correct |
18 |
Correct |
272 ms |
5412 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
252 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
6 ms |
376 KB |
Output is correct |
6 |
Correct |
13 ms |
632 KB |
Output is correct |
7 |
Correct |
24 ms |
916 KB |
Output is correct |
8 |
Correct |
66 ms |
1448 KB |
Output is correct |
9 |
Correct |
115 ms |
2516 KB |
Output is correct |
10 |
Correct |
6 ms |
420 KB |
Output is correct |
11 |
Correct |
77 ms |
1780 KB |
Output is correct |
12 |
Correct |
111 ms |
2424 KB |
Output is correct |
13 |
Correct |
92 ms |
2212 KB |
Output is correct |
14 |
Correct |
90 ms |
2152 KB |
Output is correct |
15 |
Correct |
451 ms |
5748 KB |
Output is correct |
16 |
Correct |
421 ms |
5884 KB |
Output is correct |
17 |
Correct |
275 ms |
5660 KB |
Output is correct |
18 |
Correct |
272 ms |
5412 KB |
Output is correct |
19 |
Incorrect |
392 ms |
5748 KB |
Wrong Answer [2] |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
252 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
6 ms |
376 KB |
Output is correct |
6 |
Correct |
13 ms |
632 KB |
Output is correct |
7 |
Correct |
24 ms |
916 KB |
Output is correct |
8 |
Correct |
66 ms |
1448 KB |
Output is correct |
9 |
Correct |
115 ms |
2516 KB |
Output is correct |
10 |
Correct |
6 ms |
420 KB |
Output is correct |
11 |
Correct |
77 ms |
1780 KB |
Output is correct |
12 |
Correct |
111 ms |
2424 KB |
Output is correct |
13 |
Correct |
92 ms |
2212 KB |
Output is correct |
14 |
Correct |
90 ms |
2152 KB |
Output is correct |
15 |
Correct |
451 ms |
5748 KB |
Output is correct |
16 |
Correct |
421 ms |
5884 KB |
Output is correct |
17 |
Correct |
275 ms |
5660 KB |
Output is correct |
18 |
Correct |
272 ms |
5412 KB |
Output is correct |
19 |
Incorrect |
392 ms |
5748 KB |
Wrong Answer [2] |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
252 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
6 ms |
376 KB |
Output is correct |
6 |
Correct |
13 ms |
632 KB |
Output is correct |
7 |
Correct |
24 ms |
916 KB |
Output is correct |
8 |
Correct |
66 ms |
1448 KB |
Output is correct |
9 |
Correct |
115 ms |
2516 KB |
Output is correct |
10 |
Correct |
6 ms |
420 KB |
Output is correct |
11 |
Correct |
77 ms |
1780 KB |
Output is correct |
12 |
Correct |
111 ms |
2424 KB |
Output is correct |
13 |
Correct |
92 ms |
2212 KB |
Output is correct |
14 |
Correct |
90 ms |
2152 KB |
Output is correct |
15 |
Correct |
451 ms |
5748 KB |
Output is correct |
16 |
Correct |
421 ms |
5884 KB |
Output is correct |
17 |
Correct |
275 ms |
5660 KB |
Output is correct |
18 |
Correct |
272 ms |
5412 KB |
Output is correct |
19 |
Incorrect |
392 ms |
5748 KB |
Wrong Answer [2] |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
252 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
6 ms |
376 KB |
Output is correct |
6 |
Correct |
13 ms |
632 KB |
Output is correct |
7 |
Correct |
24 ms |
916 KB |
Output is correct |
8 |
Correct |
66 ms |
1448 KB |
Output is correct |
9 |
Correct |
115 ms |
2516 KB |
Output is correct |
10 |
Correct |
6 ms |
420 KB |
Output is correct |
11 |
Correct |
77 ms |
1780 KB |
Output is correct |
12 |
Correct |
111 ms |
2424 KB |
Output is correct |
13 |
Correct |
92 ms |
2212 KB |
Output is correct |
14 |
Correct |
90 ms |
2152 KB |
Output is correct |
15 |
Correct |
451 ms |
5748 KB |
Output is correct |
16 |
Correct |
421 ms |
5884 KB |
Output is correct |
17 |
Correct |
275 ms |
5660 KB |
Output is correct |
18 |
Correct |
272 ms |
5412 KB |
Output is correct |
19 |
Incorrect |
392 ms |
5748 KB |
Wrong Answer [2] |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
252 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
6 ms |
376 KB |
Output is correct |
6 |
Correct |
13 ms |
632 KB |
Output is correct |
7 |
Correct |
24 ms |
916 KB |
Output is correct |
8 |
Correct |
66 ms |
1448 KB |
Output is correct |
9 |
Correct |
115 ms |
2516 KB |
Output is correct |
10 |
Correct |
6 ms |
420 KB |
Output is correct |
11 |
Correct |
77 ms |
1780 KB |
Output is correct |
12 |
Correct |
111 ms |
2424 KB |
Output is correct |
13 |
Correct |
92 ms |
2212 KB |
Output is correct |
14 |
Correct |
90 ms |
2152 KB |
Output is correct |
15 |
Correct |
451 ms |
5748 KB |
Output is correct |
16 |
Correct |
421 ms |
5884 KB |
Output is correct |
17 |
Correct |
275 ms |
5660 KB |
Output is correct |
18 |
Correct |
272 ms |
5412 KB |
Output is correct |
19 |
Incorrect |
392 ms |
5748 KB |
Wrong Answer [2] |
20 |
Halted |
0 ms |
0 KB |
- |