Submission #986269

#TimeUsernameProblemLanguageResultExecution timeMemory
986269vqpahmadRail (IOI14_rail)C++17
30 / 100
321 ms98736 KiB
#include"rail.h" #include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define F first #define S second #define pb push_back #define sz(a) (int)a.size() #define all(a) a.begin(),a.end() template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } const int mod = 1e9 + 7; const int MAXN = 1e6 + 15; const int inf = 0x3f3f3f3f; const ll INF = 0x3f3f3f3f3f3f3f3f; void findLocation(int n, int first, int location[], int stype[]){ vector<vector<int>> dis(n, vector<int>(n)); vector<pii> mn(n, make_pair(1e8, 1e8)); int m = 0; for (int i = 0; i < n; i++){ for (int j = i + 1; j < n; j++){ m++; dis[i][j] = getDistance(i, j); dis[j][i] = dis[i][j]; } } assert(m == (n * (n - 1) / 2)); for (int i = 0; i < n; i++){ for (int j = 0; j < n; j++){ if (i == j) continue; ckmin(mn[i], {dis[i][j], j}); } } for (int i = 0; i < n; i++){ stype[i] = -1; } location[0] = first; stype[0] = 1; for (int i = 0; i < n; i++){ for (int j = 0; j < n; j++){ if (stype[j] == -1 && stype[mn[j].S] != -1){ if (stype[mn[j].S] == 1){ stype[j] = 2; location[j] = location[mn[j].S] + mn[j].F; } else{ stype[j] = 1; location[j] = location[mn[j].S] - mn[j].F; } } } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...