#include "meetings.h"
#ifdef ONPC
#include "grader.h"
#endif
#include<bits/stdc++.h>
using namespace std;
map<vector<int>,int>mp;
int que(int a,int b,int c){
vector<int>v={a,b,c};
sort(v.begin(),v.end());
if(mp.count(v))return mp[v];
return mp[v]=Query(v[0],v[1],v[2]);
}
using uint=unsigned int;
uint seed=239239239;
uint xrand(){
seed^=seed<<2;
seed^=seed>>7;
seed^=seed<<7;
return seed;
}
mt19937 rnd(228);
void solve(vector<int>v){
cerr<<v.size()<<'\n';
// for(auto&x:v)
// cerr<<x<<' ';
// cerr<<'\n';
if(v.size()<=1)return;
shuffle(v.begin(),v.end(),rnd);
int kek=v[0];
if(v.size()>=100){
kek=que(v[0],v[1],v[2]);
swap(v[0],*find(v.begin(),v.end(),kek));
}
int cur=v[1];
vector<int>nw={};
for(int x:v){
if(x==kek)continue;
if(x==cur){
nw.push_back(x);
continue;
}
int mem=que(x,cur,kek);
if(mem==kek)
;
else if(mem==cur)
nw.push_back(x);
else
nw.push_back(x),cur=mem;
}
Bridge(min(kek,cur),max(kek,cur));
solve(nw);
set<int>nw1(nw.begin(),nw.end());
vector<int>other;
for(int x:v)
if(!nw1.count(x))other.push_back(x);
solve(other);
}
void Solve(int n) {
mp.clear();
vector<int>ord(n);
iota(ord.begin(),ord.end(),0);
solve(ord);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
304 KB |
DO NOT PRINT ANYTHING TO STANDARD OUTPUT |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
304 KB |
DO NOT PRINT ANYTHING TO STANDARD OUTPUT |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
304 KB |
DO NOT PRINT ANYTHING TO STANDARD OUTPUT |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1687 ms |
5540 KB |
DO NOT PRINT ANYTHING TO STANDARD OUTPUT |
2 |
Halted |
0 ms |
0 KB |
- |