Submission #254245

#TimeUsernameProblemLanguageResultExecution timeMemory
254245PedroBigManRail (IOI14_rail)C++14
30 / 100
561 ms196496 KiB
#include "rail.h" #include <iostream> #include <vector> #include <cmath> #include <algorithm> #include <string> #include <map> #include <unordered_map> #include <set> #include <unordered_set> #include <queue> #include <deque> #include <list> #include <iomanip> #include <stdlib.h> #include <time.h> #include <cstring> using namespace std; typedef long long int ll; typedef unsigned long long int ull; typedef long double ld; #define REP(i,a,b) for(ll i=(ll) a; i<(ll) b; i++) #define pb push_back #define mp make_pair #define pl pair<ll,ll> #define ff first #define ss second #define whole(x) x.begin(),x.end() #define DEBUG(i) cout<<"Pedro Is The Master "<<i<<endl #define INF 500000000LL #define EPS 0.00000001 #define pi 3.14159 template<class A=ll> void Out(vector<A> a) {REP(i,0,a.size()) {cout<<a[i]<<" ";} cout<<endl;} void findLocation(int N, int first, int pos[], int typ[]) { if(N==1) {pos[0]=first; typ[0]=1; return;} pos[0]=first; typ[0]=1; vector<vector<ll> > d; vector<ll> xx; REP(i,0,N) {xx.pb(-1LL);} REP(i,0,N) {d.pb(xx);} ll asks=0LL; REP(i,0,N) { REP(j,0,i) {if(asks<(N*(N-1))/2) {d[i][j]=getDistance(i,j); asks++;}} } REP(i,0,N) {d[i][i]=INF;} REP(i,0,N) {REP(j,i+1,N) {d[i][j]=d[j][i];}} vector<ll> close; REP(i,0,N) { close.pb((ll) (min_element(whole(d[i]))-d[i].begin())); } REP(i,0,N) {d[i][i]=0;} ll cr = close[0]; ll cl=close[cr]; pos[cr]=pos[0]+d[0][cr]; pos[cl]=pos[cr]-d[cl][cr]; typ[cl]=1; typ[cr]=2; REP(i,0,N) { if(i==cl || i==cr) {continue;} bool left=false; if(d[i][cl] > d[i][cr]) {left=true;} ll j = close[i]; if(left) { if(j==cr) { typ[i]=1; pos[i]=pos[cr]-d[i][cr]; } else if(d[i][cr]<d[j][cr]) { typ[i]=1; pos[i]=pos[cr]-d[i][cr]; } else { typ[i]=2; pos[i]=pos[cr]-d[j][cr]+d[i][j]; } } else { if(j==cl) { typ[i]=2; pos[i]=pos[cl]+d[i][cl]; } else if(d[i][cl]<d[j][cl]) { typ[i]=2; pos[i]=pos[cl]+d[i][cl]; } else { typ[i]=1; pos[i]=pos[cl]+d[j][cl]-d[i][j]; } } } return; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...