#include "chameleon.h"
#include <bits/stdc++.h>
using namespace std;
const int nx=1e3+5;
int vs[nx], v[nx][nx];
vector<int> d[nx];
void Solve(int N) {
for (int i=1; i<=2*N; i++) for (int j=1; j<i; j++) if (Query(vector<int> {i, j})==1) d[i].push_back(j), d[j].push_back(i);
for (int i=1; i<=2*N; i++)
{
if (vs[i]) continue;
if (d[i].size()==1)
{
Answer(i, d[i][0]);
vs[i]=vs[d[i][0]]=1;
continue;
}
bool f=0;
for (int j=0; j<2; j++)
{
vector<int> qrs;
qrs.push_back(i);
for (int k=0; k<3; k++) if (k!=j) qrs.push_back(d[i][k]);
if (Query(qrs)==1)
{
f=1;
v[i][d[i][j]]=v[d[i][j]][i]=1;
break;
}
}
if (!f) v[i][d[i][2]]=v[d[i][2]][i]=1;
}
for (int i=1; i<=2*N; i++)
{
if (vs[i]) continue;
int cnt=0;
for (int j=0; j<3; j++) if (!v[i][d[i][j]]) cnt++;
if (cnt>2) cout<<1/0;
for (int j=0; j<3; j++) if (!vs[i]&&!vs[d[i][j]]&&!v[i][d[i][j]]) vs[i]=vs[d[i][j]]=1, Answer(i, d[i][j]);
}
}
Compilation message
chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:42:27: warning: division by zero [-Wdiv-by-zero]
42 | if (cnt>2) cout<<1/0;
| ~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
15 ms |
484 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 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 |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 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 |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
856 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
856 KB |
Output is correct |
13 |
Correct |
1 ms |
600 KB |
Output is correct |
14 |
Correct |
1 ms |
860 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
732 KB |
Output is correct |
17 |
Correct |
2 ms |
856 KB |
Output is correct |
18 |
Correct |
2 ms |
856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
15 ms |
344 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
15 ms |
484 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |