#include"chameleon.h"
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
static vector<int>adj[1010];
static int ckc;
static int ch[1010];
static int tp[1010];
void dfs(int x)
{
ch[x]=ckc;
tp[x]^=1;
for(int&t:adj[x])
if(ch[t]!=ckc)
dfs(t);
return;
}
static bool chk[1010][1010];
static int dnc(int x,int s,int e,vector<int>&v)
{
if(s==e)
{
chk[x][v[s]]=chk[v[s]][x]=1;
adj[x].eb(v[s]);
adj[v[s]].eb(x);
return s;
}
int m=s+(e-s)/2;
bool f;
{
vector<int>qv;
qv.eb(x);
for(int i=s;i<=m;i++)
qv.eb(v[i]);
f=Query(qv)<(int)qv.size();
}
if(f)
return dnc(x,s,m,v);
return dnc(x,m+1,e,v);
}
static bool ck[1010][1010];
void Solve(int N)
{
int n=N;
for(int i=1;i++<n*2;)
{
vector<int>v0,v1;
for(int j=1;j<i;j++)
(tp[j]==0?v0:v1).eb(j);
{
int s=0,e=(int)v0.size()-1;
for(int it=0;it<3;it++)
{
if(s>e)
break;
vector<int>qv;
qv.eb(i);
for(int i=s;i<=e;i++)
qv.eb(v0[i]);
if(Query(qv)<(int)qv.size())
s=dnc(i,s,e,v0)+1;
else
s=e+1;
}
}
{
int s=0,e=(int)v1.size()-1;
for(int it=0;it<3;it++)
{
if(s>e)
break;
vector<int>qv;
qv.eb(i);
for(int i=s;i<=e;i++)
qv.eb(v1[i]);
if(Query(qv)<(int)qv.size())
s=dnc(i,s,e,v1)+1;
else
s=e+1;
}
}
tp[i]=0;
for(int&t:adj[i])
{
if(tp[t]==0)
{
ch[i]=++ckc;
dfs(t);
}
}
}
for(int i=0;i++<n*2;)
{
if((int)adj[i].size()==3)
{
int a=adj[i][0],b=adj[i][1],c=adj[i][2];
if(Query(vector<int>({i,a,b}))==1)
ck[i][c]=ck[c][i]=1;
else if(Query(vector<int>({i,a,c}))==1)
ck[i][b]=ck[b][i]=1;
else
ck[i][a]=ck[a][i]=1;
}
}
for(int i=0;i++<n*2;)
for(int j=i;j++<n*2;)
if(chk[i][j]&&!ck[i][j])
Answer(i,j);
return;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
34 ms |
1400 KB |
Output is correct |
4 |
Correct |
32 ms |
1408 KB |
Output is correct |
5 |
Correct |
29 ms |
1400 KB |
Output is correct |
6 |
Correct |
28 ms |
1408 KB |
Output is correct |
7 |
Correct |
28 ms |
1400 KB |
Output is correct |
8 |
Correct |
28 ms |
1400 KB |
Output is correct |
9 |
Correct |
31 ms |
1404 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
640 KB |
Output is correct |
11 |
Correct |
1 ms |
512 KB |
Output is correct |
12 |
Correct |
1 ms |
512 KB |
Output is correct |
13 |
Correct |
1 ms |
512 KB |
Output is correct |
14 |
Correct |
2 ms |
512 KB |
Output is correct |
15 |
Correct |
1 ms |
512 KB |
Output is correct |
16 |
Correct |
2 ms |
512 KB |
Output is correct |
17 |
Correct |
2 ms |
616 KB |
Output is correct |
18 |
Correct |
1 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
43 ms |
2424 KB |
Output is correct |
4 |
Correct |
45 ms |
2424 KB |
Output is correct |
5 |
Correct |
44 ms |
2428 KB |
Output is correct |
6 |
Correct |
44 ms |
2424 KB |
Output is correct |
7 |
Correct |
44 ms |
2424 KB |
Output is correct |
8 |
Correct |
45 ms |
2424 KB |
Output is correct |
9 |
Correct |
45 ms |
2424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
34 ms |
1400 KB |
Output is correct |
4 |
Correct |
32 ms |
1408 KB |
Output is correct |
5 |
Correct |
29 ms |
1400 KB |
Output is correct |
6 |
Correct |
28 ms |
1408 KB |
Output is correct |
7 |
Correct |
28 ms |
1400 KB |
Output is correct |
8 |
Correct |
28 ms |
1400 KB |
Output is correct |
9 |
Correct |
31 ms |
1404 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
0 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
640 KB |
Output is correct |
20 |
Correct |
1 ms |
512 KB |
Output is correct |
21 |
Correct |
1 ms |
512 KB |
Output is correct |
22 |
Correct |
1 ms |
512 KB |
Output is correct |
23 |
Correct |
2 ms |
512 KB |
Output is correct |
24 |
Correct |
1 ms |
512 KB |
Output is correct |
25 |
Correct |
2 ms |
512 KB |
Output is correct |
26 |
Correct |
2 ms |
616 KB |
Output is correct |
27 |
Correct |
1 ms |
512 KB |
Output is correct |
28 |
Correct |
0 ms |
384 KB |
Output is correct |
29 |
Correct |
0 ms |
384 KB |
Output is correct |
30 |
Correct |
43 ms |
2424 KB |
Output is correct |
31 |
Correct |
45 ms |
2424 KB |
Output is correct |
32 |
Correct |
44 ms |
2428 KB |
Output is correct |
33 |
Correct |
44 ms |
2424 KB |
Output is correct |
34 |
Correct |
44 ms |
2424 KB |
Output is correct |
35 |
Correct |
45 ms |
2424 KB |
Output is correct |
36 |
Correct |
45 ms |
2424 KB |
Output is correct |
37 |
Correct |
52 ms |
2424 KB |
Output is correct |
38 |
Correct |
28 ms |
1400 KB |
Output is correct |
39 |
Correct |
50 ms |
2424 KB |
Output is correct |
40 |
Correct |
50 ms |
2424 KB |
Output is correct |
41 |
Correct |
50 ms |
2448 KB |
Output is correct |
42 |
Correct |
28 ms |
1408 KB |
Output is correct |
43 |
Correct |
44 ms |
2424 KB |
Output is correct |
44 |
Correct |
49 ms |
2424 KB |
Output is correct |
45 |
Correct |
49 ms |
2424 KB |
Output is correct |