#include "chameleon.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn=1000+10;
int n,val[maxn];
vector<int>adj[maxn];
map<pair<int,int>,int>mp;
vector<int>allm[4];
bool check(vector<int>now,int u){
now.push_back(u);
if((int)now.size()==0){
return 0;
}
int res=Query(now);
if(res==(int)now.size()){
return 0;
}
return 1;
}
void createmos(){
for(int i=1;i<=2*n;i++){
while(check(allm[val[i]],i)){
val[i]++;
}
allm[val[i]].push_back(i);
}
}
int findz(vector<int>now,int u){
// cout<<(int)now.size()<<" "<<u<<endl;
if((int)now.size()==1){
return now[0];
}
int m=(int)now.size();
m>>=1;
vector<int>left,right;
for(int i=0;i<m;i++){
left.push_back(now[i]);
}
for(int i=m;i<(int)now.size();i++){
right.push_back(now[i]);
}
if(check(left,u)){
return findz(left,u);
}
return findz(right,u);
}
void finde(){
for(int i=1;i<=2*n;i++){
for(int j=0;j<4;j++){
if(j==val[i]){
continue;
}
vector<int>tof=allm[j];
sort(tof.begin(),tof.end());
for(auto x:adj[i]){
int p=lower_bound(tof.begin(),tof.end(),x)-tof.begin();
if(p!=(int)tof.size()&&tof[p]==x){
tof.erase(tof.begin()+p);
}
}
while((int)adj[i].size()<3&&check(tof,i)){
int res=findz(tof,i);
int p=lower_bound(tof.begin(),tof.end(),res)-tof.begin();
tof.erase(tof.begin()+p);
adj[i].push_back(res);
adj[res].push_back(i);
mp[make_pair(min(i,res),max(i,res))]=1;
}
}
}
}
void Solve(int N) {
n=N;
createmos();
finde();
for(int i=1;i<=2*n;i++){
if(adj[i].size()==3){
int res=Query({i,adj[i][0],adj[i][1]});
if(res==1){
mp[make_pair(min(i,adj[i][2]),max(i,adj[i][2]))]=0;
}
res=Query({i,adj[i][0],adj[i][2]});
if(res==1){
mp[make_pair(min(i,adj[i][1]),max(i,adj[i][1]))]=0;
}
res=Query({i,adj[i][2],adj[i][1]});
if(res==1){
mp[make_pair(min(i,adj[i][0]),max(i,adj[i][0]))]=0;
}
}
}
for(auto x:mp){
if(x.second==1){
// cout<<x.first.first<<" "<<x.first.second<<endl;
Answer(x.first.first,x.first.second);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
19 ms |
540 KB |
Output is correct |
4 |
Correct |
20 ms |
600 KB |
Output is correct |
5 |
Correct |
19 ms |
344 KB |
Output is correct |
6 |
Correct |
19 ms |
344 KB |
Output is correct |
7 |
Correct |
19 ms |
344 KB |
Output is correct |
8 |
Correct |
19 ms |
344 KB |
Output is correct |
9 |
Correct |
20 ms |
576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 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 |
0 ms |
344 KB |
Output is correct |
9 |
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 |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 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 |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
484 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 |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
540 KB |
Output is correct |
3 |
Correct |
31 ms |
852 KB |
Output is correct |
4 |
Correct |
31 ms |
652 KB |
Output is correct |
5 |
Correct |
32 ms |
600 KB |
Output is correct |
6 |
Correct |
31 ms |
588 KB |
Output is correct |
7 |
Correct |
31 ms |
600 KB |
Output is correct |
8 |
Correct |
32 ms |
600 KB |
Output is correct |
9 |
Correct |
32 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
19 ms |
540 KB |
Output is correct |
4 |
Correct |
20 ms |
600 KB |
Output is correct |
5 |
Correct |
19 ms |
344 KB |
Output is correct |
6 |
Correct |
19 ms |
344 KB |
Output is correct |
7 |
Correct |
19 ms |
344 KB |
Output is correct |
8 |
Correct |
19 ms |
344 KB |
Output is correct |
9 |
Correct |
20 ms |
576 KB |
Output is correct |
10 |
Correct |
1 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 |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
484 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
344 KB |
Output is correct |
26 |
Correct |
1 ms |
344 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
344 KB |
Output is correct |
29 |
Correct |
1 ms |
540 KB |
Output is correct |
30 |
Correct |
31 ms |
852 KB |
Output is correct |
31 |
Correct |
31 ms |
652 KB |
Output is correct |
32 |
Correct |
32 ms |
600 KB |
Output is correct |
33 |
Correct |
31 ms |
588 KB |
Output is correct |
34 |
Correct |
31 ms |
600 KB |
Output is correct |
35 |
Correct |
32 ms |
600 KB |
Output is correct |
36 |
Correct |
32 ms |
600 KB |
Output is correct |
37 |
Correct |
34 ms |
600 KB |
Output is correct |
38 |
Correct |
20 ms |
344 KB |
Output is correct |
39 |
Correct |
35 ms |
600 KB |
Output is correct |
40 |
Correct |
35 ms |
588 KB |
Output is correct |
41 |
Correct |
35 ms |
600 KB |
Output is correct |
42 |
Correct |
20 ms |
344 KB |
Output is correct |
43 |
Correct |
35 ms |
600 KB |
Output is correct |
44 |
Correct |
42 ms |
600 KB |
Output is correct |
45 |
Correct |
34 ms |
600 KB |
Output is correct |