#include "chameleon.h"
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
bool add(vector<int> x, vector<int> v) {
for(auto i : v) x.push_back(i);
return Query(x) == x.size();
}
vector<int> seg(vector<int> v, int l, int r) {
vector<int> res;
while(l <= r) res.push_back(v[l++]);
return res;
}
vector<int> pref(vector<int> v, int x) {
return seg(v, 0, x);
}
void Solve(int n) {
vector<vi> g(2*n+1);
vi l, r;
for(int i = 1; i <= 2*n; i++) (add(l, {i}) ? l : r).push_back(i);
//while(l.size() != n);
vector<int> c;
for(int i = 0; i < n; i++) {
int f = 0;
while(f < n && !add({l[i]}, seg(r, f, n-1))) {
for(int z = 1<<9; z>>=1;)
if(f+z < n && add(seg(r, f, f+z), {l[i]})) f += z;
f += Query({l[i], r[f]}) == 2;
g[r[f]].push_back(l[i]);
g[l[i]].push_back(r[f]);
f++;
}
}
set<pair<int, int>> bad;
for(int i = 1; i <= 2*n; i++) {
if(g[i].size() == 1) continue;
if(Query({g[i][0], g[i][1], i}) == 1) bad.insert(minmax(g[i][2], i));
else if(Query({g[i][0], g[i][2], i}) == 1) bad.insert(minmax(g[i][1], i));
else bad.insert(minmax(g[i][0], i));
}
for(int i = 1; i <= 2*n; i++) {
while(bad.count(minmax(i, g[i].back()))) g[i].pop_back();
if(i < g[i].back())
Answer(i, g[i].back());
}
}
Compilation message
chameleon.cpp: In function 'bool add(std::vector<int>, std::vector<int>)':
chameleon.cpp:7:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
return Query(x) == x.size();
~~~~~~~~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
28 ms |
384 KB |
Output is correct |
4 |
Correct |
28 ms |
384 KB |
Output is correct |
5 |
Correct |
28 ms |
384 KB |
Output is correct |
6 |
Correct |
28 ms |
384 KB |
Output is correct |
7 |
Correct |
29 ms |
512 KB |
Output is correct |
8 |
Correct |
29 ms |
384 KB |
Output is correct |
9 |
Correct |
30 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Incorrect |
5 ms |
384 KB |
Wrong Answer [1] |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Incorrect |
5 ms |
384 KB |
Wrong Answer [1] |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
53 ms |
384 KB |
Output is correct |
4 |
Correct |
57 ms |
504 KB |
Output is correct |
5 |
Correct |
53 ms |
384 KB |
Output is correct |
6 |
Correct |
54 ms |
384 KB |
Output is correct |
7 |
Correct |
55 ms |
384 KB |
Output is correct |
8 |
Correct |
54 ms |
384 KB |
Output is correct |
9 |
Correct |
53 ms |
480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
28 ms |
384 KB |
Output is correct |
4 |
Correct |
28 ms |
384 KB |
Output is correct |
5 |
Correct |
28 ms |
384 KB |
Output is correct |
6 |
Correct |
28 ms |
384 KB |
Output is correct |
7 |
Correct |
29 ms |
512 KB |
Output is correct |
8 |
Correct |
29 ms |
384 KB |
Output is correct |
9 |
Correct |
30 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Incorrect |
5 ms |
384 KB |
Wrong Answer [1] |
14 |
Halted |
0 ms |
0 KB |
- |