# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
119196 | KLPP | Meetings (JOI19_meetings) | C++14 | 643 ms | 1680 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 "meetings.h"
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define trav(a,v) for(auto a:v)
vector<pair<int,int> >edges;
int PNT;
bool cmp(int a, int b){
if(Query(PNT,a,b)==a)return true;
return false;
}
void solve(vector<int> v){
if(v.size()==1)return;
if(v.size()==2){
sort(v.begin(),v.end());
//cout<<v[0]<<" "<<v[1]<<endl;
Bridge(v[0],v[1]);
return;
}
random_shuffle(v.begin(),v.end());
int x=v[0];
int y=v[1];
//cout<<x<<" "<<y<<endl;
int answer[v.size()];
answer[0]=-1;
answer[1]=-1;
map<int,vector<int> >m;
rep(i,0,v.size()){
vector<int> N;
m[i]=N;
}
rep(i,2,v.size()){
answer[i]=Query(x,y,v[i]);
//cout<<answer[i]<<" "<<v[i]<<" "<<x<<" "<<y<<endl;
m[answer[i]].push_back(v[i]);
}
m[x].push_back(x);
m[y].push_back(y);
set<int> line;
line.insert(y);
trav(p,m){
//cout<<p.first<<" "<<p.second.size()<<" "<<x<<" "<<y<<endl;
if(p.second.size()>0){
solve(p.second);
if(p.first!=x)line.insert(p.first);
}
}
line.erase(x);
vector<int> Line;
trav(a,line)Line.push_back(a);
PNT=x;
sort(Line.begin(),Line.end(),cmp);
reverse(Line.begin(),Line.end());
Line.push_back(x);
rep(i,0,Line.size()-1){
//cout<<Line[i]<<" "<<Line[i+1]<<endl;
Bridge(min(Line[i],Line[i+1]),max(Line[i],Line[i+1]));
}
}
void Solve(int N) {
vector<int> test;
rep(i,0,N)test.push_back(i);
solve(test);
}
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... |