#include "chameleon.h"
#include <bits/stdc++.h>
#include "chameleon.h"
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vpii = vector<pii>;
namespace
{
const int mx = 500;
int variable_example = 0;
#define sz(x) int(x.size())
vvi isedge(1 + 2*mx, vi(1 + 2*mx, 0));
vi edge[1 + 2*mx];
void add_edge(int u, int v)
{
isedge[u][v] = isedge[v][u] = 1;
edge[u].push_back(v);
edge[v].push_back(u);
}
int addQuery(vi lst, int u)
{
lst.push_back(u);
return Query(lst);
}
int findEdge(int u, vi lst) //lst is list of homogenous-bipartite-colored nodes
{
if(addQuery(lst, u) == sz(lst) + 1)
return -1;
while(sz(lst) > 1)
{
vi lstleft, lstright;
for(int i = 0; i < sz(lst); i++)
{
if(i < sz(lst)/2)
lstleft.push_back(lst[i]);
else
lstright.push_back(lst[i]);
}
if(addQuery(lstleft, u) != sz(lstleft) + 1)
lst = lstleft;
else
lst = lstright;
}
return lst[0];
}
};
void Solve(int N)
{
for(int u = 1; u <= 2*N; u++)
{
vi col(1 + 2*N, -1);
queue<int> tbv;
vi collist[2];
for(int i = 1; i < u; i++)
{
if(col[i] != -1)
continue;
col[i] = 0;
tbv.push(i);
while(!tbv.empty())
{
int x = tbv.front();
tbv.pop();
for(int y : edge[x])
{
if(col[y] != -1)
continue;
col[y] = col[x] ^ 1;
tbv.push(y);
}
}
}
for(int i = 1; i < u; i++)
collist[col[i]].push_back(i);
for(int z = 0; z < 2; z++)
{
for(int t = 0; t < 3; t++)
{
int d = findEdge(u, collist[z]);
if(d == -1)
break;
else
{
add_edge(u, d);
// cerr << "adding edge " << u << ' ' << d << '\n';
vi nl;
for(int h : collist[z])
if(h != d)
nl.push_back(h);
collist[z] = nl;
}
}
}
}
vpii anslist;
vi love(1 + 2*N, 0);
for(int u = 1; u <= 2*N; u++)
{
if(sz(edge[u]) == 1)
{
;
}
else
{
assert(sz(edge[u]) == 3);
if(Query({u, edge[u][0], edge[u][1]}) == 1)
love[u] = edge[u][2];
else if(Query({u, edge[u][0], edge[u][2]}) == 1)
love[u] = edge[u][1];
else
love[u] = edge[u][0];
}
}
for(int u = 1; u <= 2*N; u++)
{
for(int v = u+1; v <= 2*N; v++)
{
if(!isedge[u][v])
continue;
if(love[u] == v)
continue;
if(love[v] == u)
continue;
Answer(u, v);
}
}
// cerr << "anslist size = " << sz(anslist) << '\n';
// for(pii al : anslist)
// {
// if(al.first < al.second)
// {
// cerr << "answer : " << al.first << ' ' << al.second << '\n';
// // Answer(al.first, al.second);
// }
// }
}
Compilation message
chameleon.cpp:17:6: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
17 | int variable_example = 0;
| ^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4268 KB |
Output is correct |
2 |
Correct |
2 ms |
4304 KB |
Output is correct |
3 |
Correct |
34 ms |
4392 KB |
Output is correct |
4 |
Correct |
32 ms |
4396 KB |
Output is correct |
5 |
Correct |
30 ms |
4304 KB |
Output is correct |
6 |
Correct |
33 ms |
4400 KB |
Output is correct |
7 |
Correct |
31 ms |
4400 KB |
Output is correct |
8 |
Correct |
31 ms |
4400 KB |
Output is correct |
9 |
Correct |
30 ms |
4392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4304 KB |
Output is correct |
2 |
Correct |
3 ms |
4304 KB |
Output is correct |
3 |
Correct |
2 ms |
4304 KB |
Output is correct |
4 |
Correct |
2 ms |
4176 KB |
Output is correct |
5 |
Correct |
3 ms |
4316 KB |
Output is correct |
6 |
Correct |
2 ms |
4176 KB |
Output is correct |
7 |
Correct |
2 ms |
4176 KB |
Output is correct |
8 |
Correct |
2 ms |
4304 KB |
Output is correct |
9 |
Correct |
3 ms |
4176 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4304 KB |
Output is correct |
2 |
Correct |
3 ms |
4304 KB |
Output is correct |
3 |
Correct |
2 ms |
4304 KB |
Output is correct |
4 |
Correct |
2 ms |
4176 KB |
Output is correct |
5 |
Correct |
3 ms |
4316 KB |
Output is correct |
6 |
Correct |
2 ms |
4176 KB |
Output is correct |
7 |
Correct |
2 ms |
4176 KB |
Output is correct |
8 |
Correct |
2 ms |
4304 KB |
Output is correct |
9 |
Correct |
3 ms |
4176 KB |
Output is correct |
10 |
Correct |
3 ms |
4252 KB |
Output is correct |
11 |
Correct |
4 ms |
4304 KB |
Output is correct |
12 |
Correct |
3 ms |
4304 KB |
Output is correct |
13 |
Correct |
3 ms |
4304 KB |
Output is correct |
14 |
Correct |
3 ms |
4304 KB |
Output is correct |
15 |
Correct |
3 ms |
4304 KB |
Output is correct |
16 |
Correct |
3 ms |
4304 KB |
Output is correct |
17 |
Correct |
3 ms |
4304 KB |
Output is correct |
18 |
Correct |
3 ms |
4304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4304 KB |
Output is correct |
2 |
Correct |
3 ms |
4224 KB |
Output is correct |
3 |
Correct |
55 ms |
4396 KB |
Output is correct |
4 |
Correct |
58 ms |
4388 KB |
Output is correct |
5 |
Correct |
58 ms |
4384 KB |
Output is correct |
6 |
Correct |
53 ms |
4384 KB |
Output is correct |
7 |
Correct |
55 ms |
4304 KB |
Output is correct |
8 |
Correct |
56 ms |
4392 KB |
Output is correct |
9 |
Correct |
58 ms |
4388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4268 KB |
Output is correct |
2 |
Correct |
2 ms |
4304 KB |
Output is correct |
3 |
Correct |
34 ms |
4392 KB |
Output is correct |
4 |
Correct |
32 ms |
4396 KB |
Output is correct |
5 |
Correct |
30 ms |
4304 KB |
Output is correct |
6 |
Correct |
33 ms |
4400 KB |
Output is correct |
7 |
Correct |
31 ms |
4400 KB |
Output is correct |
8 |
Correct |
31 ms |
4400 KB |
Output is correct |
9 |
Correct |
30 ms |
4392 KB |
Output is correct |
10 |
Correct |
3 ms |
4304 KB |
Output is correct |
11 |
Correct |
3 ms |
4304 KB |
Output is correct |
12 |
Correct |
2 ms |
4304 KB |
Output is correct |
13 |
Correct |
2 ms |
4176 KB |
Output is correct |
14 |
Correct |
3 ms |
4316 KB |
Output is correct |
15 |
Correct |
2 ms |
4176 KB |
Output is correct |
16 |
Correct |
2 ms |
4176 KB |
Output is correct |
17 |
Correct |
2 ms |
4304 KB |
Output is correct |
18 |
Correct |
3 ms |
4176 KB |
Output is correct |
19 |
Correct |
3 ms |
4252 KB |
Output is correct |
20 |
Correct |
4 ms |
4304 KB |
Output is correct |
21 |
Correct |
3 ms |
4304 KB |
Output is correct |
22 |
Correct |
3 ms |
4304 KB |
Output is correct |
23 |
Correct |
3 ms |
4304 KB |
Output is correct |
24 |
Correct |
3 ms |
4304 KB |
Output is correct |
25 |
Correct |
3 ms |
4304 KB |
Output is correct |
26 |
Correct |
3 ms |
4304 KB |
Output is correct |
27 |
Correct |
3 ms |
4304 KB |
Output is correct |
28 |
Correct |
2 ms |
4304 KB |
Output is correct |
29 |
Correct |
3 ms |
4224 KB |
Output is correct |
30 |
Correct |
55 ms |
4396 KB |
Output is correct |
31 |
Correct |
58 ms |
4388 KB |
Output is correct |
32 |
Correct |
58 ms |
4384 KB |
Output is correct |
33 |
Correct |
53 ms |
4384 KB |
Output is correct |
34 |
Correct |
55 ms |
4304 KB |
Output is correct |
35 |
Correct |
56 ms |
4392 KB |
Output is correct |
36 |
Correct |
58 ms |
4388 KB |
Output is correct |
37 |
Correct |
60 ms |
4304 KB |
Output is correct |
38 |
Correct |
31 ms |
4304 KB |
Output is correct |
39 |
Correct |
54 ms |
4400 KB |
Output is correct |
40 |
Correct |
59 ms |
4388 KB |
Output is correct |
41 |
Correct |
53 ms |
4396 KB |
Output is correct |
42 |
Correct |
33 ms |
4392 KB |
Output is correct |
43 |
Correct |
58 ms |
4388 KB |
Output is correct |
44 |
Correct |
56 ms |
4400 KB |
Output is correct |
45 |
Correct |
55 ms |
4368 KB |
Output is correct |