#include "Memory2_lib.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define cerr if(false) cerr
const int N = 1e6+100, M = 1e5+10, K = 52, MX = 30;
mt19937 rng(234256453);
int rn(int l, int r){
return uniform_int_distribution<int>(l,r)(rng);
}
void Solve(int t, int n){
vi v;
for(int i = 1; i <= n*2; ++i){
v.pb(i-1);
}
vector<vi> res(2*n);
while(v.size() > 2){
int m = v.size();
m--;
int x = rn(0, m);
int y = rn(0, m);
int z = rn(0, m);
while(x==y) y=rn(0,m);
while(x==z||y==z) z=rn(0,m);
int X = Flip(v[x], v[y]);
int Y = Flip(v[x], v[z]);
int Z = Flip(v[y], v[z]);
cerr << v[x] << ' ' << v[y] << ' ' << v[z] << '\n';
cerr << X << ' ' << Y << ' ' << Z << '\n';
cerr << '\n';
if(X == Y && Y == Z) continue; // unlucky case
if(X == Y){
cerr << "# " << v[x] << ' ' << X << '\n';
res[X].pb(v[x]);
v.erase(v.begin()+x);
}else if(X == Z){
cerr << "# " << v[y] << ' ' << Y << '\n';
res[X].pb(v[y]);
v.erase(v.begin()+y);
}else{
cerr << "# " << v[z] << ' ' << Z << '\n';
res[Z].pb(v[z]);
v.erase(v.begin()+z);
}
}
for(int pos: v) res[n-1].pb(pos);
for(int i = 0; i < n; ++i){
// cerr << res[i][0] << ' ' << res[i][1] << ' ' << i << '\n';
Answer(res[i][0], res[i][1], i);
}
return;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |