#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);
}
} // namespace
void Solve(int N) {
n=N;
for(int i=1;i<=2*n;i++) {
for(int j=i+1;j<=2*n;j++){
if (f2(i,j)==1) {
arr[i][j]=1;
arr[j][i]=1;
deg[i]++;
deg[j]++;
//printf(".%d %d\n",i,j);
}
}
}
queue<int> q;
for(int i=1;i<=n*2;i++) {
if (deg[i]!=1) {
continue;
}
for(int j=1;j<=n*2;j++) {
if (arr[i][j]==1) {
used[i]=true;
used[j]=true;
ret[i]=j;
ret[j]=i;
//printf("%d %d\n",i,j);
}
}
}
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]) {
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*2;i++) {
if (ret[i]!=0&&i<ret[i]) {
Answer(i,ret[i]);
}
}
for(int i=1;i<=n*2;i++) {
for(int j=i+1;j<=n*2;j++) {
if (cnt[i][j]==2) {
Answer(i,j);
}
}
}
}
Compilation message
chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:71:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
71 | for(int i=0;i<v.size();i++){
| ~^~~~~~~~~
chameleon.cpp:72:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
72 | for(int j=i+1;j<v.size();j++) {
| ~^~~~~~~~~
chameleon.cpp: At global scope:
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 |
Runtime error |
9 ms |
444 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
2 ms |
336 KB |
Output is correct |
11 |
Correct |
3 ms |
208 KB |
Output is correct |
12 |
Correct |
2 ms |
336 KB |
Output is correct |
13 |
Correct |
2 ms |
336 KB |
Output is correct |
14 |
Correct |
2 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
2 ms |
336 KB |
Output is correct |
17 |
Correct |
2 ms |
336 KB |
Output is correct |
18 |
Correct |
2 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Runtime error |
10 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 |
Runtime error |
9 ms |
444 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |