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>
#include <vector>
using namespace std;
void Solve(int n)
{
vector <int> qry;
int h;
vector <int> candid[2*n];
int sim[2*n], flove[2*n];
for(int i = 0; i<2*n; i++)
{
flove[i] = -1;
for(int j = 0; j<i; j++)
{
qry.clear();
qry.push_back(i+1);
qry.push_back(j+1);
h = Query(qry);
if(h == 1)
{
candid[i].push_back(j);
candid[j].push_back(i);
}
}
}
int B;
for(int i = 0; i<2*n; i++)
{
if(candid[i].size() == 1)
{
sim[i] = candid[i][0];
continue;
}
flove[i] = candid[i][0];
qry = {i+1, candid[i][0]+1, candid[i][1]+1};
h = Query(qry);
if(h == 1)
flove[i] = candid[i][2];
qry = {i+1, candid[i][0]+1, candid[i][2]+1};
h = Query(qry);
if(h == 1)
flove[i] = candid[i][1];
}
for(int i = 0; i<2*n; i++)
{
if(candid[i].size() == 1)
continue;
for(int k = 0; k<3; k++)
{
B = candid[i][k];
if(flove[i] == B)
continue;
if(flove[B] == i)
continue;
sim[i] = B;
}
}
for(int i = 0; i<2*n; i++)
{
if(sim[i] > i)
Answer(i+1, sim[i]+1);
}
}
# | 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... |