This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define DBG 1
// chrono::system_clock::now().time_since_epoch().count()
#include<bits/stdc++.h>
#include "chameleon.h"
//#include<ext/pb_ds/tree_policy.hpp>
//#include<ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define debug(x) if (DBG) cerr << #x << " = " << x << endl;
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> pii;
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
namespace {
const int MAXN = 1005;
vector<int> adj[MAXN];
int partner[MAXN], loves[MAXN], n;
}
void Solve(int _n) {
n = _n;
for (int i = 1; i <= 2 * n; ++i) {
for (int j = 1; j <= 2 * n; ++j) {
if (i != j && Query({i, j}) == 1) {
adj[i].pb(j);
}
}
}
for (int i = 1; i <= 2 * n; ++i) {
assert(adj[i].size() == 1 || adj[i].size() == 3);
if (adj[i].size() == 1) {
partner[i] = adj[i][0];
continue;
}
while (Query({i, adj[i][0], adj[i][1]}) != 1) {
rotate(adj[i].begin(), adj[i].begin() + 1, adj[i].end());
}
loves[i] = adj[i][2];
}
for (int i = 1; i <= 2 * n; ++i) {
if (loves[adj[i][0]] == i) {
partner[i] = adj[i][1];
}
else {
partner[i] = adj[i][0];
}
}
for (int i = 1; i <= 2 * n; ++i) {
if (i < partner[i]) {
Answer(i, partner[i]);
}
}
}
# | 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... |