# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1155735 | modwwe | Memory 2 (JOI16_memory2) | C++20 | 0 ms | 0 KiB |
//#include "gap.h"
//#include "mushrooms.h"
//#include "prize.h"
#include "Memory2_lib.h"
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
//#define int long long
#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define modwwe int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task2 "ftree"
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define mask(k) (1<<k)
#define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms";
using namespace std;
#define getchar_unlocked getchar
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l,int r)
{
return uniform_int_distribution<int>(l,r)(rd);
}
void phongbeo();
const int inf = 1e16;
const ll mod2 = 1e9+7;
const ll base=67;
int n, m, s1, s2, s4, s3, sf, k, s5, s6, mx, s7, s8, s9, mx2, res, dem2 = 0, dem = 0, s33, dem3, dem4, mid, l2, r2, center;
int i, s10, s12,k1,k2,k3,s11,lim,w,l,r,dem5,dem6,dem7,dem9;
int kk;
int t;
int el = 19;/*
main()
{
if(fopen(task2".inp","r"))
{
fin(task2);
fou(task2);
}
if(fopen(task".inp","r"))
{
fin(task);
fou(task);
}
ios_base::sync_with_stdio(0);
cout.tie(0);
cin.tie(0);
/// cin>>s1;
//int t;cin>>t; while(t--)
phongbeo();
checktime
}*/
struct ib
{
int a,b;
};
int c[3];
vector<int> per,h,v[10001];/*
void Answer(int x,int y,int z)
{
dem++;
if(h[x]!=z||h[y]!=z)
{
cout<<"nguvcl";
return;
}
}
int flip(int x,int y)
{
dem5++;
if(per[h[x]]<per[h[y]])return h[x];
return h[y];
}*/
ib get(int x,int y,int z)
{
c[0]=flip(x,y);
c[1]=flip(y,z);
c[2]=flip(z,x);
if(c[0]==c[1])
{
v[c[0]].pb(y);
return{x,z};
}
if(c[0]==c[2])
{
v[c[0]].pb(x);
return {y,z};
}
if(c[1]==c[2])
{
v[c[1]].pb(z);
return {x,y};
}
assert(0);
}
void Solve(int T,int N)
{
n=N*2;
if(n==2)
{
Answer(0,1,0);
}
else
{
ib x= {0,1};
for(int i=2; i<n; i++)
x=get(x.a,x.b,i);
Answer(x.a,x.b,flip(x.a,x.b));
for(int i=0; i<n; i++)
if(v[i].size()!=0)
Answer(v[i][0],v[i][1],i);
}
}/*
void phongbeo()
{
cin>>n;
for(int i=0; i<n; i++)
per.pb(i);
shuffle(per.begin(),per.end(),rd);
for(auto x:per)
cout<<x<<" ";
for(int i=0; i<n; i++)
h.pb(i),h.pb(i);
shuffle(h.begin(),h.end(),rd);
down
for(auto x:h)
cout<<x<<" ";
Solve(1,n);
down
cout<<dem<<" "<<dem5<<"\n";
}*/