#include "chameleon.h"
#include <bits/stdc++.h>
using namespace std;
void Solve(int n) {
vector<int> vis(n*2+1),deg(n*2+1);
vector<int> adj[n*2+1];
map<pair<int,int>,int> m;
for(int i=1;i<=n*2;i++){
for(int j=i+1;j<=n*2;j++){
if(Query({i,j})==1){
//cout<<i<<' '<<j<<endl;
adj[i].push_back(j);
adj[j].push_back(i);
deg[i]++,deg[j]++;
}
}
}
for(int i=1;i<=n*2;i++){
if(vis[i])continue;
if(deg[i]==1){
Answer(i,adj[i][0]);
vis[i]=1;
vis[adj[i][0]]=1;
}
}
for(int i=1;i<=n*2;i++){
if(vis[i])continue;
vector<int> t;
for(int j:adj[i]){
//if(vis[j])continue;
t.push_back(j);
//cout<<j<<' ';
}
//cout<<endl;
vector<int> rec(3);
rec[0]=Query({t[0],t[1],i});
rec[1]=Query({t[0],t[2],i});
rec[2]=Query({t[1],t[2],i});
auto upd=[&](int a,int b){
if(a>b)swap(a,b);
if(m[{a,b}])Answer(a,b);
m[{a,b}]++;
};
if(rec[0]==1){
upd(i,t[0]);
upd(i,t[1]);
}
if(rec[1]==1){
upd(i,t[0]);
upd(i,t[2]);
}
if(rec[2]==1){
upd(i,t[1]);
upd(i,t[2]);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
596 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
15 ms |
476 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
600 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
600 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
600 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
600 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
2 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
15 ms |
344 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
596 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
15 ms |
476 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |