# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
577601 | 2022-06-15T06:21:36 Z | Belgutei | Rail (IOI14_rail) | C++17 | 71 ms | 468 KB |
#include "rail.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define ff first #define ss second #define pb push_back #define mk make_pair int n; int d[5005][5005]; int mn = 1e9, mx, x, y; void findLocation(int N, int F, int location[], int stype[]) { //getDistance(0,0); n = N; location[0] = F; stype[0] = 1; // for(int i = 1; i < n; i ++) { d[0][i] = getDistance(0,i); if(mn > d[0][i]) { mn = d[0][i]; x = i; } } location[x] = F + mn; stype[x] = 2; // mx = location[0]; y = 0; for(int i = 0; i < n; i ++) { if(i == 0 || i == x) continue; d[x][i] = getDistance(x,i); if(d[0][x] + d[x][i] == d[0][i]) { location[i] = location[x] - d[x][i]; stype[i] = 1; if(mx < location[i]) { mx = location[i]; y = i; } } } // for(int j = 0; j < n; j ++) { if(j == 0 || j == x || j == y) continue; if( d[0][j] + F == (d[x][j] - (location[x] - location[y]) * 2) + location[x] ) { location[j] = d[0][j] + F; stype[j] = 2; } } mn = 1e9,mx = 0;; int a,b; for(int i = 0; i < n; i ++) { if(stype[i] != 0 && mn > location[i]) { mn = location[i]; a = i; } if(stype[i] != 0 && mx < location[i]) { mx = location[i]; b = i; } } for(int i = 0; i < n; i ++) { if(stype[i] != 0) continue; d[a][i] = getDistance(a,i); int tmp = location[a] + d[a][i]; if(tmp < location[0]) { location[i] = tmp; stype[i] = 2; } } for(int i = 0; i < n; i ++) { if(stype[i] != 0) continue; d[b][i] = getDistance(b,i); int tmp = location[b] - d[b][i]; if(tmp > location[x]) { location[i] = tmp; stype[i] = 1; } } return; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 300 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 67 ms | 468 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 71 ms | 468 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |