#include "chameleon.h"
#include <bits/stdc++.h>
using namespace std;
int lst[1100];
bool vis[1100];
vector<int> blonk;
set<int> v[2];
vector<int> adjlst[1100];
int connect[1100];
void ffs(int i, int p){
v[1 - p].erase(i);
v[p].insert(i);
vis[i] = true;
lst[i] = p;
for(int j : adjlst[i]){
if(!vis[j]) ffs(j,1-p);
}
}
int fid(vector<int> v, int i){
if(v.size() == 1) return v[0];
vector<int> temp = {i};
int m = (v.size() - 1)/2;
for(int i = 0; i <= m; i++){
temp.push_back(v[i]);
}
if(temp.size() != Query(temp)){
temp.clear();
for(int i = 0; i <= m; i++){
temp.push_back(v[i]);
}
return fid(temp,i);
}
else{
temp.clear();
for(int i = m + 1; i < v.size(); i++){
temp.push_back(v[i]);
}
return fid(temp,i);
}
}
void Solve(int N) {
for(int i = 1; i <= N * 2; i++){
lst[i] = -1;
}
for(int i = 1; i <= N * 2; i++){
vector<int> temp(v[1].begin(),v[1].end());
vector<int> ext;
vector<int> con;
while(temp.size() != Query(temp)){
for(int j = 1; j <= N * 2; j++){
vis[j] = false;
}
int num = fid(temp,i);
ext.clear();
for(int i : temp){
if(i == num) continue;
ext.push_back(i);
}
temp = ext;
con.push_back(num);
}
temp.clear();
for(int i = 0; i < v[2].size(); i++){
temp.push_back(0);
}
copy(v[2].begin(),v[2].end(),temp.begin());
while(temp.size() != Query(temp)){
int num = fid(temp,i);
ext.clear();
for(int i : temp){
if(i == num) continue;
ext.push_back(i);
}
temp = ext;
con.push_back(num);
}
for(int j : con){
adjlst[i].push_back(j);
adjlst[j].push_back(i);
}
for(int j = 1; j <= N * 2; j++){
vis[j] = false;
}
ffs(i,0);
}
for(int i = 1; i <= N * 2; i++) connect[i] = -1;
for(int i = 1; i <= N * 2; i++){
if(adjlst[i].size() == 3){
int h1 = Query({i,adjlst[i][0],adjlst[i][1]});
int h2 = Query({i,adjlst[i][0],adjlst[i][2]});
int h3 = Query({i,adjlst[i][1],adjlst[i][2]});
if(h1 == h2){
connect[i] = adjlst[i][0];
}
else if(h1 == h3){
connect[i] = adjlst[i][1];
}
else{
connect[i] = adjlst[i][2];
}
}
}
for(int i : v[0]){
if(adjlst[i].size() == 1){
Answer(i,adjlst[i][0]);
}
else{
for(int j : adjlst[i]){
if(connect[i] == j) continue;
if(connect[j] == i) continue;
Answer(i,j);
}
}
}
}
Compilation message
chameleon.cpp: In function 'int fid(std::vector<int>, int)':
chameleon.cpp:34:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
34 | if(temp.size() != Query(temp)){
| ~~~~~~~~~~~~^~~~~~~~~~~~~~
chameleon.cpp:43:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | for(int i = m + 1; i < v.size(); i++){
| ~~^~~~~~~~~~
chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:60:27: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
60 | while(temp.size() != Query(temp)){
| ~~~~~~~~~~~~^~~~~~~~~~~~~~
chameleon.cpp:78:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::set<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
78 | for(int i = 0; i < v[2].size(); i++){
| ~~^~~~~~~~~~~~~
chameleon.cpp:83:27: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
83 | while(temp.size() != Query(temp)){
| ~~~~~~~~~~~~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
852 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
852 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |