# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1011750 | vjudge1 | Magic Show (APIO24_show) | C++17 | 0 ms | 0 KiB |
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 <bits/stdc++.h>
#include "Bob.h"
using namespace std;
// you may define some global variables, but it does not work if you try to transfer any information from function Alice() to function Bob() through these variables.
// you had better not use the same global variables in function Alice() and in function Bob().
set<int> vv[5000];
vector<int> VVV(4999),v2v[5000];
int cap[5000],pos[5000];
mt19937 rng2(1987042837);
void gen2(){
int sum=0;
for(int i=2;i<5000;i++)
sum+=cap[i]=log2(i-1);
sum/=60;
vector<int>Z(60),Z2(4998);
iota(Z.begin(),Z.end(),0);
iota(Z2.begin(),Z2.end(),2);
iota(VVV.begin(),VVV.end(),1);
shuffle(Z.begin(),Z.end(),rng2);
shuffle(VVV.begin(),VVV.end(),rng2);
for(int i=0;i<4999;i++)
pos[VVV[i]]=i;
for(auto j:Z){
int x=sum;
shuffle(Z2.begin(),Z2.end(),rng2);
for(auto i:Z2)if(cap[i]*!vv[i].count(j)*x)
cap[i]--,vv[i].insert(j),x--;
}
for(auto i:Z2)while(cap[i]){
vector<int>VVV(60);
iota(VVV.begin(),VVV.end(),0);
shuffle(VVV.begin(),VVV.end(),rng2);
int x=-1;
for(auto j:VVV)
if(!vv[i].count(j)){
x=j;
break;
}
vv[i].insert(x);
cap[i]--;
}
for(auto i:Z2)
for(auto j:vv[i])
v2v[i].push_back(j);
for(auto i:Z2)shuffle(v2v[i].begin(),v2v[i].end(),rng2);
}
long long Bob(std::vector<std::pair<int,int>> V){
long long ans=0;
gen2();
int tot=0;
for(auto i:V){
auto[a,b]=i;
if(pos[a]>pos[b])
swap(a,b);
int k=pos[b]+1,q=pos[a];
vector<int>v22=v2v[k];
reverse(v22.begin(),v22.end());
for(auto i:v22){
ans|=(q&1ll)<<i;
q/=2;
}
}
return max(ans,1ll);
}