#include "chameleon.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>>S(4), B(1005), adjs(1005);
vector<bool>vis(1005, 0);
int y;
void ans(int a, int b){
if(vis[a]||vis[b])return;
Answer(a, b);
vis[a]=1, vis[b]=1;
return;
}
void BS(int x, int j, int l, int r){
if(adjs[x].size()==3)return;
if(x==2){
//~ cout<<"sz:"<<adjs[2].size()<<"\n";
}
if(l==r){
if(x==2||S[j][l]==2){
//~ cout<<x<<" xxx "<<S[j][l]<<"\n";
}
adjs[x].push_back(S[j][l]);
adjs[S[j][l]].push_back(x);
if(x==2||x==3){
//~ cout<<"sz2:"<<adjs[2].size()<<"\n";
}
return;
}
int m=(l+r)/2;
vector<int>v1={x}, v2={x};
vector<bool>v(10005,0);
v[x]=1;
for(int i=l; i<=m; i++){
if(v[S[j][i]]){
//~ cout<<"a\n";
}
v1.push_back(S[j][i]);
v[S[j][i]]=1;
}
for(int i=m+1; i<=r; i++){
if(v[S[j][i]]){
//~ cout<<"b\n";
}
v2.push_back(S[j][i]);
v[S[i][j]]=1;
}
if(Query(v1)!=m-l+2){
BS(x, j, l, m);
}
if(adjs[x].size()==3)return;
if(Query(v2)!=r-m+1){
BS(x, j, m+1, r);
}
}
void Solve(int n) {
n*=2;
y=n;
for(int i=1; i<=n; i++){
vector<bool>X(4, 0);
for(int j=0; j<4; j++){
if(adjs[i].size()==3)break;
S[j].push_back(i);
if(Query(S[j])!=S[j].size()){
X[j]=1;
S[j].pop_back();
BS(i, j, 0, S[j].size()-1);
}else{
X[j]=0;
S[j].pop_back();
}
//~ cout<<j<<" ";
}
//~ cout<<"\n";
for(int j=0; j<4; j++){
if(!X[j]){
S[j].push_back(i);
break;
}
}
//~ cout<<i<<"----------------\n";
//~ for(int j=0; j<4; j++){
//~ cout<<j<<": ";
//~ for(int a:S[j])cout<<a<<" ";
//~ cout<<"\n";
//~ }
//~ cout<<"\n---------------\n";
}
//~ cout<<"\naaaa ";
//~ for(int a:adjs[7])cout<<a<<" ";
//~ cout<<"aaaa \n";
for(int i=1; i<=n; i++){
if(adjs[i].size()==1){
ans(i, adjs[i][0]);
}else{
//~ cout<<i<<"\n";
for(int j=0; j<3; j++){
if(j==2){
B[i].push_back(adjs[i][j]);
B[adjs[i][j]].push_back(i);
break;
}
vector<int>A={i};
for(int a=0;a<=2; a++){
//~ cout<<adjs[i][a]<<" ";
if(a!=j)A.push_back(adjs[i][a]);
}
//~ cout<<"\n";
if(Query(A)==1){
B[i].push_back(adjs[i][j]);
B[adjs[i][j]].push_back(i);
break;
}
}
}
}
for(int i=1; i<=n; i++){
if(vis[i])continue;
for(int a:adjs[i]){
if(a!=B[i][0]&&a!=B[i][1]){
ans(i, a);
}
}
}
}
//~ #include "chameleon.h"
//~ #include <bits/stdc++.h>
//~ using namespace std;
//~ int n;
//~ int get(int x, int l ,int r, int y){
//~ vector<int>p;
//~ if(y!=-1){
//~ for(int i=l; i<=r; i++)p.push_back(i);
//~ p.push_back(y);
//~ return Query(p);
//~ }else if(x==-1){
//~ for(int i=l; i<=r; i++) p.push_back(i);
//~ return Query(p);
//~ }else{
//~ for(int i=l ; i<=r; i++){
//~ if(i==x)continue;
//~ p.push_back(i);
//~ }
//~ return Query(p);
//~ }
//~ }
//~ int rec(int x, int l, int r){
//~ int m=(l+r)/2;
//~ if(l==r) return l;
//~ if(x<=m){
//~ if(get(x, 1, m, -1)==get(-1, 1, m, -1)) return rec(x, 1, m);
//~ else return rec(x, m+1, r);
//~ }else{
//~ if(get(-1, 1, m, -1)==get(-1, 1, m, x)) return rec(x, 1, m);
//~ else return rec(x, m+1, r);
//~ }
//~ }
//~ void Solve(int N) {
//~ n=N*2;
//~ vector<bool>vis(n+1);
//~ for(int i=1; i<=n; i++){
//~ if(vis[i])continue;
//~ int j=rec(i, 1, n);
//~ Answer(i, j);
//~ vis[i]=1, vis[j]=1;
//~ }
//~ }
Compilation message
chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:63:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(Query(S[j])!=S[j].size()){
~~~~~~~~~~~^~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Runtime error |
5 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Runtime error |
5 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Runtime error |
5 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Runtime error |
8 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Runtime error |
5 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |