제출 #607622

#제출 시각아이디문제언어결과실행 시간메모리
607622MohamedFaresNebili철로 (IOI14_rail)C++14
8 / 100
107 ms98536 KiB
#include <bits/stdc++.h> #include "rail.h" /// #pragma GCC optimize ("Ofast") /// #pragma GCC target ("avx2") /// #pragma GCC optimize("unroll-loops") using namespace std; using ll = long long; using ld = long double; #define ff first #define ss second #define pb push_back #define all(x) (x).begin(), (x).end() #define lb lower_bound const int MOD = 998244353; int DP[5005][5005]; int query(int i, int j) { if(i == j) return 0; if(DP[i][j] != -1) return DP[i][j]; return DP[i][j] = DP[j][i] = getDistance(i, j); } void findLocation(int n, int first, int location[], int stype[]) { memset(DP, -1, sizeof DP); array<int, 2> A[n]; A[0] = {0, 0}; location[0] = first, stype[0] = 1; for(int l = 1; l < n; l++) A[l] = {query(0, l), l}; sort(A, A + n); int L = 0, R = A[1][1]; stype[R] = 2; location[R] = first + A[1][0]; for(int l = 2; l < n; l++) { int i = A[l][1]; int U = query(L, i); int V = query(R, i); int K = query(0, i); if(query(0, R) + K == V) { stype[i] = 2; location[i] = location[L] + U; if(location[i] > location[R]) R = i; continue; } if(K + V == query(0, R)) { stype[i] = 1; location[i] = location[R] - V; if(location[i] < location[L]) L = i; continue; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...