# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
423736 | tqbfjotld | Chameleon's Love (JOI20_chameleon) | C++14 | 3 ms | 456 KiB |
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;
namespace {
int p[505];
int inv[505];
vector<int> adjl[505];
}
void Solve(int N) {
for (int x = 1; x<=2*N; x++){
for (int y = x+1; y<=2*N; y++){
int res = Query({x,y});
if (res==1){
adjl[x].push_back(y);
adjl[y].push_back(x);
}
}
}
for (int x = 1; x<=2*N; x++){
if (adjl[x].size()==3){
int res1 = Query({x,adjl[x][0],adjl[x][1]});
int res2 = Query({x,adjl[x][1],adjl[x][2]});
int res3 = Query({x,adjl[x][0],adjl[x][2]});
if (res1==1){
p[x] = adjl[x][2];
}
else if (res2==1){
p[x] = adjl[x][0];
}
else{
p[x] = adjl[x][1];
}
inv[p[x]] = x;
}
}
for (int x = 1; x<=2*N; x++){
if (adjl[x].size()<3){
if (x<adjl[x][0]){
Answer(x,adjl[x][0]);
}
}
else{
int other = -1;
for (auto y : adjl[x]){
if (y==p[x]) continue;
if (y==inv[x]) continue;
other = y;
}
if (x<other){
Answer(x,other);
}
}
}
}
Compilation message (stderr)
# | 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... |