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 <bits/stdc++.h>
#include "chameleon.h"
#include <vector>
#define query Query
#define answer Answer
constexpr int M = 1005;
using namespace std;
vector<vector<int>> sasiedzi(M);
vector<vector<int>> g(M);
int syn[M];
bool uzyte[M];
void Solve(int n) {
for(int i=1; i<=n*2; i++){
for(int j=1; j<=n*2; j++){
if(i==j) continue;
if(query({i, j}) == 1) sasiedzi[i].push_back(j);
}
}
//for(int i=1; i<=2*n; i++){
//cout<<i<<": ";
//for(auto j:sasiedzi[i]) cout<<j<<" ";
//cout<<endl;
//}
//cout<<endl;
for(int i=1; i<=n*2; i++){
//cout<<"I: "<<i<<" "<<sasiedzi[i].size()<<endl;
if(sasiedzi[i].size()!=1){
//cout<<i<<"S: "<<sasiedzi[i][0]<<" "<<sasiedzi[i][1]<<" "<<sasiedzi[i][2]<<endl;
if(query({i, sasiedzi[i][0], sasiedzi[i][1]})==1) syn[i] = sasiedzi[i][2];
if(query({i, sasiedzi[i][0], sasiedzi[i][2]})==1) syn[i] = sasiedzi[i][1];
if(query({i, sasiedzi[i][2], sasiedzi[i][1]})==1) syn[i] = sasiedzi[i][0];
}
}
for(int i=1; i<=n*2; i++){
if(syn[i]!=0){
g[i].push_back(syn[i]);
g[syn[i]].push_back(i);
}
}
//cout<<"XD"<<endl;
for(int i=1; i<=n*2; i++){
sort(g[i].begin(), g[i].end());
if(syn[i]==0){
if(uzyte[min(i, sasiedzi[i][0])] == 0){
//cout<<i<<","<<sasiedzi[i][0]<<endl;
uzyte[min(i, sasiedzi[i][0])] = 1;
answer(i, sasiedzi[i][0]);
}
}
else{
if(g[i][0] == sasiedzi[i][0] && g[i][1] == sasiedzi[i][1]){
if(uzyte[min(i, sasiedzi[i][2])] == 0){
//cout<<i<<","<<sasiedzi[i][2]<<endl;
uzyte[min(i, sasiedzi[i][2])] = 1;
answer(i, sasiedzi[i][2]);
}
}
else if(g[i][0] == sasiedzi[i][0] && g[i][1] == sasiedzi[i][2]){
if(uzyte[min(i, sasiedzi[i][1])] == 0){
//cout<<i<<","<<sasiedzi[i][1]<<endl;
uzyte[min(i, sasiedzi[i][1])] = 1;
answer(i, sasiedzi[i][1]);
}
}
else if(g[i][0] == sasiedzi[i][1] && g[i][1] == sasiedzi[i][2]){
if(uzyte[min(i, sasiedzi[i][0])] == 0){
//cout<<i<<","<<sasiedzi[i][0]<<endl;
uzyte[min(i, sasiedzi[i][0])] = 1;
answer(i, sasiedzi[i][0]);
}
}
}
}
}
# | 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... |