#include "chameleon.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second
#define endl '\n'
#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);s<e?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;
vector<int> ind_set[4];
vector<int> same[1005];
int nxt[1005];
set<int> test(int i,int pos){
set<int> res;
while (true){
vector<int> v;
for (auto &it:ind_set[i]) if (!res.count(it)) v.pub(it);
if (v.empty()) break;
v.pub(pos);
if (Query(v)==sz(v)) break;
v.pob();
while (sz(v)!=1){
vector<int> l,r;
rep(x,0,sz(v)/2) l.pub(v[x]);
rep(x,sz(v)/2,sz(v)) r.pub(v[x]);
l.pub(pos);
int val=Query(l);
l.pob();
if (val==sz(l)+1) v=r;
else v=l;
}
res.insert(v[0]);
}
return res;
}
void Solve(int N) {
n=N;
vector<int> proc;
rep(x,1,2*n+1) proc.pub(x);
rep(x,0,sz(proc)) swap(proc[x],proc[rng()%(x+1)]);
for (auto &x:proc){
bool ins=false;
rep(y,0,4){
auto temp=test(y,x);
for (auto &it:temp){
//cout<<x<<" "<<it<<endl;
same[it].pub(x);
same[x].pub(it);
}
if (temp.empty() && !ins){
ind_set[y].pub(x);
ins=true;
}
}
}
memset(nxt,-1,sizeof(nxt));
rep(x,1,2*n+1) if (sz(same[x])==3){
if (Query({x,same[x][0],same[x][1]})==1){
nxt[x]=same[x][2];
}
else if (Query({x,same[x][0],same[x][2]})==1){
nxt[x]=same[x][1];
}
else {
nxt[x]=same[x][0];
}
}
rep(x,1,2*n+1){
if (sz(same[x])==1){
//cout<<x<<" "<<same[x][0]<<endl;
if (x<same[x][0]) Answer(x,same[x][0]);
}
else{
for (auto &it:same[x]) if (nxt[it]!=x && nxt[x]!=it){
//cout<<x<<" "<<it<<endl;
if (x<it) Answer(x,it);
}
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
29 ms |
476 KB |
Output is correct |
4 |
Correct |
26 ms |
328 KB |
Output is correct |
5 |
Correct |
31 ms |
384 KB |
Output is correct |
6 |
Correct |
26 ms |
328 KB |
Output is correct |
7 |
Correct |
27 ms |
360 KB |
Output is correct |
8 |
Correct |
34 ms |
328 KB |
Output is correct |
9 |
Correct |
26 ms |
328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
1 ms |
328 KB |
Output is correct |
7 |
Correct |
1 ms |
328 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
1 ms |
328 KB |
Output is correct |
7 |
Correct |
1 ms |
328 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
328 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
2 ms |
328 KB |
Output is correct |
13 |
Correct |
2 ms |
456 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
1 ms |
328 KB |
Output is correct |
17 |
Correct |
2 ms |
328 KB |
Output is correct |
18 |
Correct |
1 ms |
328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
65 ms |
328 KB |
Output is correct |
4 |
Correct |
53 ms |
472 KB |
Output is correct |
5 |
Correct |
63 ms |
360 KB |
Output is correct |
6 |
Correct |
53 ms |
364 KB |
Output is correct |
7 |
Correct |
55 ms |
360 KB |
Output is correct |
8 |
Correct |
53 ms |
364 KB |
Output is correct |
9 |
Correct |
63 ms |
328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
29 ms |
476 KB |
Output is correct |
4 |
Correct |
26 ms |
328 KB |
Output is correct |
5 |
Correct |
31 ms |
384 KB |
Output is correct |
6 |
Correct |
26 ms |
328 KB |
Output is correct |
7 |
Correct |
27 ms |
360 KB |
Output is correct |
8 |
Correct |
34 ms |
328 KB |
Output is correct |
9 |
Correct |
26 ms |
328 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
1 ms |
328 KB |
Output is correct |
17 |
Correct |
1 ms |
328 KB |
Output is correct |
18 |
Correct |
1 ms |
328 KB |
Output is correct |
19 |
Correct |
1 ms |
328 KB |
Output is correct |
20 |
Correct |
1 ms |
328 KB |
Output is correct |
21 |
Correct |
2 ms |
328 KB |
Output is correct |
22 |
Correct |
2 ms |
456 KB |
Output is correct |
23 |
Correct |
1 ms |
328 KB |
Output is correct |
24 |
Correct |
1 ms |
328 KB |
Output is correct |
25 |
Correct |
1 ms |
328 KB |
Output is correct |
26 |
Correct |
2 ms |
328 KB |
Output is correct |
27 |
Correct |
1 ms |
328 KB |
Output is correct |
28 |
Correct |
1 ms |
328 KB |
Output is correct |
29 |
Correct |
1 ms |
328 KB |
Output is correct |
30 |
Correct |
65 ms |
328 KB |
Output is correct |
31 |
Correct |
53 ms |
472 KB |
Output is correct |
32 |
Correct |
63 ms |
360 KB |
Output is correct |
33 |
Correct |
53 ms |
364 KB |
Output is correct |
34 |
Correct |
55 ms |
360 KB |
Output is correct |
35 |
Correct |
53 ms |
364 KB |
Output is correct |
36 |
Correct |
63 ms |
328 KB |
Output is correct |
37 |
Correct |
54 ms |
328 KB |
Output is correct |
38 |
Correct |
26 ms |
328 KB |
Output is correct |
39 |
Correct |
58 ms |
328 KB |
Output is correct |
40 |
Correct |
59 ms |
356 KB |
Output is correct |
41 |
Correct |
55 ms |
360 KB |
Output is correct |
42 |
Correct |
36 ms |
356 KB |
Output is correct |
43 |
Correct |
54 ms |
328 KB |
Output is correct |
44 |
Correct |
55 ms |
368 KB |
Output is correct |
45 |
Correct |
54 ms |
364 KB |
Output is correct |