#include "chameleon.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
int variable_example = 1;
int n;
bool arr[101][101];
int deg[101];
bool used[101];
int ret[101];
int cnt[101][101];
int f2(int x,int y) {
vector<int> v;
v.push_back(x);
v.push_back(y);
return Query(v);
}
int f3(int x,int y,int z) {
vector<int> v;
v.push_back(x);
v.push_back(y);
v.push_back(z);
return Query(v);
}
int f(int ind,int l,int r) {
if (l>r) {
return -1;
}
while (l<r) {
int mid=(l+r)/2;
vector<int> vec;
vec.push_back(ind);
for(int i=l;i<=mid;i++) {
vec.push_back(i);
}
int got=Query(vec);
if (got==mid-l+2) {
l=mid+1;
}
else {
r=mid;
}
}
vector<int> vec;
vec.push_back(ind);
vec.push_back(l);
if (Query(vec)==1) {
return l;
}
else {
return -1;
}
}
} // namespace
void Solve(int N) {
n=N;
for(int i=1;i<=n;i++) {
int one;
int two=-1;
int three=-1;
one=f(i,n+1,n*2);
two=f(i,one+1,n*2);
if (two!=-1) {
three=f(i,two+1,n*2);
}
arr[i][one]=true;
deg[i]=1;
deg[one]++;
if (two!=-1) {
arr[i][two]=true;
arr[i][three]=true;
deg[two]++;
deg[three]++;
deg[i]=3;
}
}
for(int i=1;i<=n*2;i++) {
if (deg[i]!=1) {
continue;
}
used[i]=true;
for(int j=1;j<=n*2;j++) {
if (arr[i][j]||arr[j][i]) {
ret[i]=j;
ret[j]=i;
used[j]=true;
}
}
}
for(int now=1;now<=n*2;now++) {
if (used[now]) {
continue;
}
vector<int> v;
for(int j=1;j<=n*2;j++) {
if (arr[now][j]||arr[j][now]) {
//printf("%d %d\n",now,j);
v.push_back(j);
}
}
assert(v.size()==3);
for(int i=0;i<v.size();i++){
for(int j=i+1;j<v.size();j++) {
int one=v[i];
int two=v[j];
if (f3(now,one,two)==1) {
cnt[now][one]++;
cnt[one][now]++;
cnt[now][two]++;
cnt[two][now]++;
}
}
}
}
for(int i=1;i<=n;i++) {
if (ret[i]!=0) {
//printf(".%d %d\n",i,ret[i]);
Answer(i,ret[i]);
}
}
for(int i=1;i<=n*2;i++) {
for(int j=n+1;j<=n*2;j++) {
if (cnt[i][j]==2) {
//printf("%d %d\n",i,j);
Answer(i,j);
}
}
}
}
Compilation message
chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:109:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
109 | for(int i=0;i<v.size();i++){
| ~^~~~~~~~~
chameleon.cpp:110:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
110 | for(int j=i+1;j<v.size();j++) {
| ~^~~~~~~~~
chameleon.cpp: At global scope:
chameleon.cpp:15:5: warning: 'int {anonymous}::f2(int, int)' defined but not used [-Wunused-function]
15 | int f2(int x,int y) {
| ^~
chameleon.cpp:7:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
7 | int variable_example = 1;
| ^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Incorrect |
1 ms |
208 KB |
Wrong Answer [1] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Runtime error |
1 ms |
464 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Runtime error |
1 ms |
464 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Runtime error |
8 ms |
464 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Incorrect |
1 ms |
208 KB |
Wrong Answer [1] |
4 |
Halted |
0 ms |
0 KB |
- |