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 "meetings.h"
#include <bits/stdc++.h>
#define pb push_back
#define all(v) ((v).begin(), (v).end())
#define sortv(v) sort(all(v))
#define sz(v) ((int)(v).size())
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define umax(a, b) (a)=max((a), (b))
#define umin(a, b) (a)=min((a), (b))
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define rep(i,n) FOR(i,1,n)
#define rep0(i,n) FOR(i,0,(int)(n)-1)
#define FI first
#define SE second
#define INF 2000000000
#define INFLL 1000000000000000000LL
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAX_N = 2000;
int N;
vector<int> vt[MAX_N+1];
vector<int> v;
vector<int> arr;
vector<int> tmp;
int now;
bool sf(int a, int b){
int k = Query(now, a, b);
return (k==a);
}
void b(int x, int y){
Bridge(min(x, y), max(x, y));
}
void calc(){
while(!v.empty()){
now = v.back(); v.pop_back();
if(vt[now].size()==0) continue;
int r = vt[now][rand()%vt[now].size()];
//cout<<now<<" "<<r<<endl;
tmp = vt[now];
while(!vt[now].empty()) vt[now].pop_back();
for(int i=0; i<tmp.size(); i++){
int j = tmp[i];
if(j==r){
continue;
}
//cout<<now<<" "<<r<<" "<<j<<endl;
int k = Query(now, r, j);
if(k==j){
arr.pb(j);
}else{
vt[k].pb(j);
}
}
if(arr.empty()){
b(now, r);
v.pb(now); v.pb(r); continue;
}
sort(arr.begin(), arr.end(), sf);
v.pb(now); v.pb(r);
b(now, arr[0]); b(arr.back(), r);
int prv = arr.back(); arr.pop_back(); v.pb(prv);
while(!arr.empty()){
b(arr.back(), prv); prv = arr.back(); arr.pop_back();
v.pb(prv);
}
}
}
void Solve(int n) {
srand(time(NULL));
N = n;
for(int i=1; i<N; i++){
vt[0].pb(i);
}
v.pb(0);
calc();
}
Compilation message (stderr)
meetings.cpp: In function 'void calc()':
meetings.cpp:53:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<tmp.size(); i++){
~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |