#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define st first
#define nd second
#define pq priority_queue
#define all(x) begin(x), end(x)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int i_inf = 1e9;
const ll inf = 1e18;
const ll mod = 1e9+7;
const ld eps = 1e-13;
const ld pi = 3.14159265359;
mt19937 _rand(time(NULL));
clock_t z;
const int mxn = 2e5+5;
#include "meetings.h"
/*
void bridge(int a, int b){
cout<<"bridge : "<<a<<"-"<<b<<endl;
}
int Query(int a, int b, int c){
cout<<a<<' '<<b<<' '<<c<<endl;
int d;
cin >> d;
return d;
}*/
int cpr[mxn];
vector<int> Sort(vector<int> v, int l, int r){
if((int)v.size() <= 1) return v;
int pivot = v[_rand()%(int)v.size()];
vector<int> L;
vector<int> R;
for(auto u : v){
if(u == pivot) continue;
int q = Query(l, u, pivot);
if(q == u){
L.pb(u);
}
else{
R.pb(u);
}
}
L = Sort(L, l, pivot);
R = Sort(R, pivot, r);
v.clear();
for(auto u : L) v.pb(u);
v.pb(pivot);
for(auto u : R) v.pb(u);
return v;
}
void solve(vector<int> v){
sort(all(v));
v.erase(unique(all(v)), v.end());
int m = (int)v.size();
if(m <= 1) return;
if(m == 2){
Bridge(v[0], v[1]);
return;
}
int a = _rand()%m;
int b = _rand()%(m-1);
if(b >= a) ++b;
a = v[a];
b = v[b];
vector<int> g[m];
fr(i, 0, m){
cpr[v[i]] = i;
g[i].pb(v[i]);
}
vector<int> diam;
fr(i, 0, m){
if(v[i] == a || v[i] == b) continue;
int q = Query(a, b, v[i]);
g[cpr[q]].pb(v[i]);
if(q != a && q != b) diam.pb(q);
}
sort(all(diam));
diam.erase(unique(all(diam)), diam.end());
diam = Sort(diam, a, b);
diam.insert(diam.begin(), a);
diam.pb(b);
fr(i, 0, (int)diam.size()-1){
Bridge(diam[i], diam[i+1]);
}
fr(i, 0, m){
solve(g[i]);
}
}
void Solve(int N){
vector<int> v;
fr(i, 0, N) v.pb(i);
solve(v);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
328 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
328 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
328 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
74 ms |
644 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |