This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
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++){
| ~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |