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 "Memory2_lib.h"
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) ( (int)(x).size() )
using LL = long long;
mt19937 rng( (uint32_t)chrono::steady_clock::now().time_since_epoch().count() );
void Solve(int T, int N){
vector<int> a(N << 1, -1);
vector<int> rem(N << 1); iota(all(rem), 0);
while (sz(rem) > 1) {
int chosen = rem[rng() % sz(rem)];
for (const auto &i : rem) if (i ^ chosen) a[i] = Flip(chosen, i);
a[chosen] = -1;
for (int i = 0; i < N; ++i) if (count(all(a), i) & 1) {
a[chosen] = i;
break ;
}
vector<int> nRem;
for (const auto &i : rem) if (i ^ chosen && a[i] == a[chosen]) nRem.emplace_back(i);
rem.swap(nRem);
}
for (int i = 0; i < N; ++i) {
int x = (int)(find(all(a), i) - a.begin() ),
y = (int)(find( (x + 1) + all(a), i) - a.begin() );
Answer(x, y, 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... |