제출 #341521

#제출 시각아이디문제언어결과실행 시간메모리
341521FlashGamezzz철로 (IOI14_rail)C++11
30 / 100
418 ms98576 KiB
#include <iostream> #include <cstdlib> #include <cstdio> #include <fstream> #include <algorithm> #include <vector> #include <utility> #include <map> #include "rail.h" using namespace std; int n, dists[5000][5000] = {}; void findLocation(int N, int first, int location[], int stype[]){ n = N; for (int i = 0; i < n; i++){ for (int j = i+1; j < n; j++){ dists[i][j] = getDistance(i, j); dists[j][i] = dists[i][j]; } } int diff = 10000000, cd = -1; for (int i = 1; i < n; i++){ if (dists[0][i] < diff){ diff = dists[0][i]; cd = i; } } int td = diff, cc = -1;; diff = 10000000; for (int i = 0; i < n; i++){ if (i != cd && dists[cd][i] < diff){ diff = dists[cd][i]; cc = i; } } location[0] = first; stype[0] = 1; location[cd] = first+td; stype[cd] = 2; location[cc] = location[cd] - diff; stype[cc] = 1; for (int i = 1; i < n; i++){ if (i != cd && i != cc){ int mv = 10000000, mi = -1; for (int j = 0; j < n; j++){ if (j != i && dists[i][j] < mv){ mv = dists[i][j]; mi = j; } } if (dists[i][cd] < dists[i][cc]){ //left if (mi == cd){ location[i] = first+diff-dists[i][cd]; stype[i] = 1; } else if (dists[mi][cd] < dists[i][cd]){ // C <- _D_ 0 D location[i] = first+diff-dists[mi][cd]+mv; stype[i] = 2; } else { // _C_ -> D 0 D location[i] = first+diff-dists[i][cd]; stype[i] = 1; } } else { //right if (mi == cc){ location[i] = first+dists[i][cc]; stype[i] = 2; } else if (dists[mi][cc] < dists[i][cc]){ // 0 D _C_ -> D location[i] = first+dists[mi][cc]-mv; stype[i] = 1; } else { // 0 D C _D_ location[i] = first+dists[i][cc]; stype[i] = 2; } } } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...