#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a))
#define MEM_1(a) memset((a),-1,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define COMPRESS(a) sort(ALL(a));a.resize(unique(ALL(a))-a.begin())
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<ld> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 998244353;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[] = { -1,-2,1,-2,2,-1,2,1 }, ddy[] = { -2,-1,-2,1,-1,2,1,2 };
#include "chameleon.h"
Vi v[1001],tmp[2];
bool chk[1001],e[1001][1001];
void dfs(int N,int c){
chk[N]=1;
tmp[c].pb(N);
for(int next:v[N]){
if(!chk[next])dfs(next,c^1);
}
}
void go(Vi &vv){
int N=vv.size();
int f=0;
fup(kk,0,2,1){
int l=f,r=N-2;
while(l<=r){
int m=l+r>>1;
Vi tt={vv.back()};
fup(k,f,m,1)tt.pb(vv[k]);
if(Query(tt)!=tt.size())r=m-1;
else l=m+1;
}
if(l>N-2)return;
v[vv.back()].pb(vv[l]);
v[vv[l]].pb(vv.back());
f=l+1;
}
}
void Solve(int N){
fup(i,1,2*N,1){
tmp[0].clear();
tmp[1].clear();
MEM0(chk);
fup(j,1,i-1,1)if(!chk[j])dfs(j,0);
fup(j,0,1,1){
tmp[j].pb(i);
if(tmp[j].size()>1 && Query(tmp[j])!=tmp[j].size())go(tmp[j]);
}
}
MEM0(chk);
fup(i,1,2*N,1){
if(v[i].size()==1){
if(chk[i] || chk[v[i][0]])continue;
chk[i]=chk[v[i][0]]=1;
Answer(i,v[i][0]);
continue;
}
int a=v[i][0],b=v[i][1],c=v[i][2];
int t=Query({i,a,b});
if(t==1){
e[i][c]=1;
continue;
}
t=Query({i,a,c});
if(t==1){
e[i][b]=1;
continue;
}
t=Query({i,c,b});
if(t==1){
e[i][a]=1;
continue;
}
}
fup(i,1,2*N,1){
if(chk[i])continue;
if(v[i].size()==3){
chk[i]=1;
int a=v[i][0],b=v[i][1],c=v[i][2];
if(!e[i][a] && !e[a][i]){
chk[a]=1;
Answer(i,a);
continue;
}
if(!e[i][b] && !e[b][i]){
chk[b]=1;
Answer(i,b);
continue;
}
if(!e[i][c] && !e[c][i]){
chk[c]=1;
Answer(i,c);
continue;
}
}
}
}
/*
int main(){
}*/
Compilation message
chameleon.cpp: In function 'void go(Vi&)':
chameleon.cpp:10:30: warning: unnecessary parentheses in declaration of 'kk' [-Wparentheses]
10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
| ^
chameleon.cpp:56:2: note: in expansion of macro 'fup'
56 | fup(kk,0,2,1){
| ^~~
chameleon.cpp:59:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
59 | int m=l+r>>1;
| ~^~
chameleon.cpp:10:30: warning: unnecessary parentheses in declaration of 'k' [-Wparentheses]
10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
| ^
chameleon.cpp:61:4: note: in expansion of macro 'fup'
61 | fup(k,f,m,1)tt.pb(vv[k]);
| ^~~
chameleon.cpp:62:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
62 | if(Query(tt)!=tt.size())r=m-1;
| ~~~~~~~~~^~~~~~~~~~~
chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
| ^
chameleon.cpp:72:2: note: in expansion of macro 'fup'
72 | fup(i,1,2*N,1){
| ^~~
chameleon.cpp:10:30: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
| ^
chameleon.cpp:76:3: note: in expansion of macro 'fup'
76 | fup(j,1,i-1,1)if(!chk[j])dfs(j,0);
| ^~~
chameleon.cpp:10:30: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
| ^
chameleon.cpp:77:3: note: in expansion of macro 'fup'
77 | fup(j,0,1,1){
| ^~~
chameleon.cpp:79:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
79 | if(tmp[j].size()>1 && Query(tmp[j])!=tmp[j].size())go(tmp[j]);
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~
chameleon.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
| ^
chameleon.cpp:83:2: note: in expansion of macro 'fup'
83 | fup(i,1,2*N,1){
| ^~~
chameleon.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
| ^
chameleon.cpp:107:2: note: in expansion of macro 'fup'
107 | fup(i,1,2*N,1){
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
47 ms |
364 KB |
Output is correct |
4 |
Correct |
47 ms |
352 KB |
Output is correct |
5 |
Correct |
48 ms |
364 KB |
Output is correct |
6 |
Correct |
47 ms |
360 KB |
Output is correct |
7 |
Correct |
49 ms |
352 KB |
Output is correct |
8 |
Correct |
49 ms |
460 KB |
Output is correct |
9 |
Correct |
59 ms |
352 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
328 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Correct |
0 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 |
0 ms |
328 KB |
Output is correct |
9 |
Correct |
0 ms |
328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
328 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Correct |
0 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 |
0 ms |
328 KB |
Output is correct |
9 |
Correct |
0 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 |
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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
328 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
69 ms |
1292 KB |
Output is correct |
4 |
Correct |
68 ms |
1296 KB |
Output is correct |
5 |
Correct |
77 ms |
1344 KB |
Output is correct |
6 |
Correct |
81 ms |
1368 KB |
Output is correct |
7 |
Correct |
70 ms |
1344 KB |
Output is correct |
8 |
Correct |
78 ms |
1368 KB |
Output is correct |
9 |
Correct |
67 ms |
1260 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
47 ms |
364 KB |
Output is correct |
4 |
Correct |
47 ms |
352 KB |
Output is correct |
5 |
Correct |
48 ms |
364 KB |
Output is correct |
6 |
Correct |
47 ms |
360 KB |
Output is correct |
7 |
Correct |
49 ms |
352 KB |
Output is correct |
8 |
Correct |
49 ms |
460 KB |
Output is correct |
9 |
Correct |
59 ms |
352 KB |
Output is correct |
10 |
Correct |
0 ms |
328 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
0 ms |
328 KB |
Output is correct |
13 |
Correct |
0 ms |
328 KB |
Output is correct |
14 |
Correct |
0 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 |
0 ms |
328 KB |
Output is correct |
18 |
Correct |
0 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 |
328 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 |
1 ms |
328 KB |
Output is correct |
27 |
Correct |
1 ms |
328 KB |
Output is correct |
28 |
Correct |
0 ms |
328 KB |
Output is correct |
29 |
Correct |
0 ms |
328 KB |
Output is correct |
30 |
Correct |
69 ms |
1292 KB |
Output is correct |
31 |
Correct |
68 ms |
1296 KB |
Output is correct |
32 |
Correct |
77 ms |
1344 KB |
Output is correct |
33 |
Correct |
81 ms |
1368 KB |
Output is correct |
34 |
Correct |
70 ms |
1344 KB |
Output is correct |
35 |
Correct |
78 ms |
1368 KB |
Output is correct |
36 |
Correct |
67 ms |
1260 KB |
Output is correct |
37 |
Correct |
81 ms |
1380 KB |
Output is correct |
38 |
Correct |
47 ms |
368 KB |
Output is correct |
39 |
Correct |
80 ms |
1344 KB |
Output is correct |
40 |
Correct |
80 ms |
1344 KB |
Output is correct |
41 |
Correct |
81 ms |
1256 KB |
Output is correct |
42 |
Correct |
48 ms |
480 KB |
Output is correct |
43 |
Correct |
70 ms |
1344 KB |
Output is correct |
44 |
Correct |
83 ms |
1272 KB |
Output is correct |
45 |
Correct |
81 ms |
1472 KB |
Output is correct |