#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb emplace_back
#define AI(i) begin(i), end(i)
template<class T> bool chmin(T &a, T b) { return b < a && (a = b, true); }
template<class T> bool chmax(T &a, T b) { return a < b && (a = b, true); }
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] = ", args)
void kout() { cerr << endl; }
template<class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ', kout(b...); }
template<class T> void debug(T l, T r) { while (l != r) cerr << *l << " \n"[next(l)==r], ++l; }
#else
#define DE(...) 0
#define debug(...) 0
#endif
#include "chameleon.h"
#include <vector>
namespace {
const int MAX_N = 1010;
int qry(vector<int> p) { for (int &i : p) ++i; return Query(p); }
int n, love[MAX_N];
vector<int> edge[MAX_N];
void ans(int a, int b) { ++a, ++b; if (a > b) return; Answer(a, b); }
void find(int x, vector<int> g) {
if (g.empty()) return;
vector<int> q = g;
q.pb(x);
if (qry(q) == q.size()) return;
if (g.size() == 1) {
edge[x].pb(g[0]), edge[g[0]].pb(x);
return;
}
int mid = g.size()/2;
vector<int> l(begin(g), begin(g)+mid), r(begin(g)+mid, end(g));
find(x, l), find(x, r);
}
void make_edge() {
vector<int> one, two;
for (int i = 0;i < n + n;++i) {
one.pb(i);
if (qry(one) != one.size()) {
one.pop_back();
two.pb(i);
}
}
assert(one.size() == n && two.size() == n);
for (int i = 0;i < n;++i) {
find(one[i], two);
vector<int> three = one;
three.erase(find(AI(three), one[i]));
find(one[i], three);
}
}
}
void Solve(int N) {
n = N;
fill(love, love + n + n, -1);
make_edge();
for (int i = 0;i < n + n;++i) {
assert(edge[i].size() == 1 || edge[i].size() == 3);
if (edge[i].size() == 1) continue;
int cnt = 0;
for (int j = 0;j < 3;++j) {
vector<int> p {i};
for (int k = 0;k < 3;++k) if (j != k) p.pb( edge[i][k] );
if (qry(p) == 1) {
love[ i ] = edge[i][j];
++cnt;
}
}
assert(cnt == 1);
}
for (int i = 0;i < n + n;++i) {
for (int j = 0;j < edge[i].size();++j) {
if (love[i] != edge[i][j] && love[ edge[i][j] ] != i)
ans(i, edge[i][j]);
}
}
}
Compilation message
chameleon.cpp: In function 'void {anonymous}::find(int, std::vector<int>)':
chameleon.cpp:33:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | if (qry(q) == q.size()) return;
| ~~~~~~~^~~~~~~~~~~
chameleon.cpp: In function 'void {anonymous}::make_edge()':
chameleon.cpp:47:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | if (qry(one) != one.size()) {
| ~~~~~~~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
from chameleon.cpp:1:
chameleon.cpp:53:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
53 | assert(one.size() == n && two.size() == n);
| ~~~~~~~~~~~^~~~
chameleon.cpp:53:39: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
53 | assert(one.size() == n && two.size() == n);
| ~~~~~~~~~~~^~~~
chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:90:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
90 | for (int j = 0;j < edge[i].size();++j) {
| ~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
34 ms |
400 KB |
Output is correct |
4 |
Correct |
29 ms |
328 KB |
Output is correct |
5 |
Correct |
28 ms |
328 KB |
Output is correct |
6 |
Correct |
28 ms |
328 KB |
Output is correct |
7 |
Correct |
28 ms |
396 KB |
Output is correct |
8 |
Correct |
28 ms |
400 KB |
Output is correct |
9 |
Correct |
28 ms |
408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Runtime error |
1 ms |
456 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Runtime error |
1 ms |
456 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Incorrect |
37 ms |
328 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
34 ms |
400 KB |
Output is correct |
4 |
Correct |
29 ms |
328 KB |
Output is correct |
5 |
Correct |
28 ms |
328 KB |
Output is correct |
6 |
Correct |
28 ms |
328 KB |
Output is correct |
7 |
Correct |
28 ms |
396 KB |
Output is correct |
8 |
Correct |
28 ms |
400 KB |
Output is correct |
9 |
Correct |
28 ms |
408 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Runtime error |
1 ms |
456 KB |
Execution killed with signal 6 |
14 |
Halted |
0 ms |
0 KB |
- |