Submission #598985

#TimeUsernameProblemLanguageResultExecution timeMemory
598985promaRail (IOI14_rail)C++17
56 / 100
740 ms98508 KiB
#include "rail.h" #include <bits/stdc++.h> using namespace std; int d[5001][5001], used[5001]; void findLocation(int N, int first, int location[], int stype[]) { memset(d, -1, sizeof(d)); for (int i = 0; i < N; i ++) { d[i][i] = 0; } int nxt = -1, mn = 1e9; for (int i = 1; i < N; i ++) { if (d[0][i] == -1) { d[0][i] = d[i][0] = getDistance(0, i); } if (mn > d[0][i]) { mn = d[0][i]; nxt = i; } } stype[0] = 1; location[0] = first; stype[nxt] = 2; location[nxt] = first + mn; // finding D that go before 0 for (int i = 1; i < N; i ++) { if (i == nxt) continue; int flag = 0; for (int j = 1; j < N; j ++) { if (j == i or j == nxt) continue; if (d[j][i] == -1) { d[j][i] = d[i][j] = getDistance(i, j); } if (d[nxt][j] == -1) { d[nxt][j] = d[j][nxt] = getDistance(nxt, j); } if (d[0][i] == d[0][nxt] + d[nxt][j] + d[j][i]) { flag = 1; stype[i] = 2; location[i] = first + d[0][nxt] - d[nxt][j] + d[j][i]; break; } } if (!flag) { for (int j = 1; j < N; j ++) { if (i == j) continue; if (d[j][i] == -1) { d[j][i] = d[i][j] = getDistance(i, j); } if (d[0][i] == d[0][j] + d[j][i]) { flag = 1; stype[i] = 1; location[i] = first + d[0][j] - d[j][i]; break; } } } if (!flag) { stype[i] = 2; location[i] = first + d[0][i]; } // cout << i << ": " << stype[i] << " " << location[i] << endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...