# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
238722 | b00n0rp | Meetings (JOI19_meetings) | C++17 | 1156 ms | 1016 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 "meetings.h"
using namespace std;
typedef long double LD;
typedef long long ll;
#define pb push_back
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(v) v.begin(),v.end()
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
#define F first
#define S second
vi gg[2005];
vpii edges;
int globalu;
bool cmp(int x,int y){
return Query(globalu,x,y) == x;
}
void dfs(int u){
vi mkc;
for(auto x:gg[u]) mkc.pb(x);
gg[u].clear();
if(mkc.size() == 0) return;
if(mkc.size() == 1){
edges.pb({u,mkc[0]});
return;
}
int v = mkc[rand()%mkc.size()];
vi path;
for(auto x:mkc){
if(x == v) continue;
int lol = Query(u,v,x);
if(lol == x) path.pb(x);
else gg[lol].pb(x);
}
path.pb(v);
globalu = u;
sort(all(path),cmp);
edges.pb({u,path[0]});
REP(i,path.size()-1) edges.pb({path[i],path[i+1]});
dfs(u);
for(auto x:path) dfs(x);
}
void Solve(int n){
int root = rand()%n;
REP(i,n){
if(i != root){
gg[root].pb(i);
}
}
dfs(root);
for(auto x:edges){
Bridge(min(x.F,x.S),max(x.F,x.S));
}
}
Compilation message (stderr)
# | 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... |