제출 #252515

#제출 시각아이디문제언어결과실행 시간메모리
252515eohomegrownappsRail (IOI14_rail)C++14
0 / 100
83 ms504 KiB
#include "rail.h" #include <bits/stdc++.h> using namespace std; int n; //int getDistance(int i, int j); void findLocation(int N, int first, int location[], int stype[]){ //1: lhs (up-down) //2: rhs (down-up) n=N; location[0]=first; stype[0]=1; if (n==1){ return; } vector<pair<int,int>> distfrom0(n-1); for (int i = 1; i<n; i++){ distfrom0[i-1]={getDistance(0,i),i}; } sort(distfrom0.begin(),distfrom0.end()); //last c, first d int indlastc = 0; int indfirstd = distfrom0[0].second; stype[indlastc]=2; location[indlastc]=first+distfrom0[0].first; for (int i = 2; i<n; i++){ int ind = distfrom0[i].second; int distc = getDistance(indlastc,ind); int distd = getDistance(indfirstd,ind); if (distc>distd){ location[ind]=location[indfirstd]-distd; stype[ind]=1; } else { location[ind]=location[indlastc]+distc; stype[ind]=2; } } 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...