#include "chameleon.h"
#include <bits/stdc++.h>
using namespace std;
int ask(vector<int> p){
for (int &v: p) v++;
return Query(p);
}
void ans(int a, int b){
if (a > b) return;
Answer(a+1, b+1);
}
void Solve(int N) {
int n = N;
vector<vector<int>> a(2*n, vector<int> (2*n, -1));
for (int i=0; i<a.size(); i++)
for (int j=0; j<i; j++)
a[i][j] = a[j][i] = ask({i, j});
vector<vector<int>> g(a.size()), rg(a.size());
for (int i=0; i<a.size(); i++){
vector<int> pos;
for (int j=0; j<a.size(); j++)
if (a[i][j] == 1) pos.push_back(j);
if (pos.size() == 1){
ans(i, pos[0]);
continue;
}
assert(pos.size() == 3);
rg[i] = pos;
int xy = ask({i, pos[0], pos[1]});
int yz = ask({i, pos[1], pos[2]});
int nxt = -1;
if (xy == 1) nxt = pos[2];
else if (yz == 1) nxt = pos[0];
else nxt = pos[1];
g[nxt].push_back(i);
g[i].push_back(nxt);
}
for (int i=0; i<rg.size(); i++){
if (rg[i].size() == 0) continue;
vector<int> a = rg[i], b = g[i];
assert(b.size() == 2);
for (int v: b){
auto it = find(a.begin(), a.end(), v);
assert(it != a.end());
a.erase(it);
}
ans(i, a[0]);
}
}
Compilation message
chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:17:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
17 | for (int i=0; i<a.size(); i++)
| ~^~~~~~~~~
chameleon.cpp:22:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | for (int i=0; i<a.size(); i++){
| ~^~~~~~~~~
chameleon.cpp:24:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
24 | for (int j=0; j<a.size(); j++)
| ~^~~~~~~~~
chameleon.cpp:46:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | for (int i=0; i<rg.size(); i++){
| ~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
17 ms |
4372 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 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 |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 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 |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
2 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
2 ms |
344 KB |
Output is correct |
18 |
Correct |
2 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
28 ms |
4184 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
17 ms |
4372 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |