# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
307407 | 2020-09-28T04:27:57 Z | arthur_nascimento | Stations (IOI20_stations) | C++14 | 1081 ms | 1284 KB |
#include "stations.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define debug #define maxn 2020 int ini[maxn]; int fim[maxn]; int mrk[maxn]; int h[maxn]; vector<int> L[maxn]; int cur = 0; void dfs(int x){ debug("dfs %d\n",x); ini[x] = cur++; for(int i : L[x]) if(ini[i] == 0 && i > 0){ h[i] = 1 + h[x]; dfs(i); } fim[x] = cur++; } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { cur = 0; for(int i=0;i<2*n;i++) L[i].clear(), h[i] = ini[i] = fim[i] = 0, mrk[i] = 0; for(int i=0;i<n-1;i++){ L[u[i]].pb(v[i]); L[v[i]].pb(u[i]); } dfs(0); vector<int> ret; for(int i=0;i<n;i++){ if(h[i]%2 == 0) ret.pb(ini[i]); else ret.pb(fim[i]); } for(int i : ret) mrk[i] = 1; for(int i=1;i<2*n;i++) mrk[i] += mrk[i-1]; for(int &i : ret) i = mrk[i]; for(int i : ret) debug("%d ",i); debug("\n"); return ret; } int find_next_station(int s, int t, std::vector<int> c) { debug("qr %d %d ~",s,t); for(int i : c) debug("%d ",i); debug("\n"); if(c.size() == 1) return c[0]; sort(c.begin(), c.end()); if(s < c[0]){ // S é entrada, c[i] é saida int pai = c[c.size()-1]; if(t < s) return pai; if(c.size() >= 2 && t > c[c.size()-2]) return pai; for(int i=0;i<c.size();i++){ if(t <= c[i]) return c[i]; } } else { // S é saida, c[i] é entrada int pai = c[0]; if(t > s) return pai; if(t < c[1]) return pai; for(int i=1;i<c.size()-1;i++){ if(t < c[i+1]) return c[i]; } return c[c.size()-1]; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 636 ms | 1128 KB | Output is correct |
2 | Correct | 453 ms | 1124 KB | Output is correct |
3 | Correct | 948 ms | 768 KB | Output is correct |
4 | Correct | 689 ms | 968 KB | Output is correct |
5 | Correct | 606 ms | 968 KB | Output is correct |
6 | Correct | 458 ms | 1280 KB | Output is correct |
7 | Correct | 451 ms | 1184 KB | Output is correct |
8 | Correct | 2 ms | 1100 KB | Output is correct |
9 | Correct | 5 ms | 896 KB | Output is correct |
10 | Correct | 1 ms | 768 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 456 ms | 896 KB | Output is correct |
2 | Correct | 510 ms | 1152 KB | Output is correct |
3 | Correct | 893 ms | 1024 KB | Output is correct |
4 | Correct | 639 ms | 896 KB | Output is correct |
5 | Correct | 613 ms | 968 KB | Output is correct |
6 | Correct | 481 ms | 904 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 540 ms | 1136 KB | Output is correct |
2 | Correct | 462 ms | 1124 KB | Output is correct |
3 | Correct | 910 ms | 896 KB | Output is correct |
4 | Correct | 696 ms | 968 KB | Output is correct |
5 | Correct | 614 ms | 968 KB | Output is correct |
6 | Correct | 474 ms | 1132 KB | Output is correct |
7 | Correct | 466 ms | 1024 KB | Output is correct |
8 | Correct | 3 ms | 976 KB | Output is correct |
9 | Correct | 5 ms | 968 KB | Output is correct |
10 | Correct | 1 ms | 1100 KB | Output is correct |
11 | Correct | 593 ms | 768 KB | Output is correct |
12 | Correct | 482 ms | 1244 KB | Output is correct |
13 | Correct | 469 ms | 1120 KB | Output is correct |
14 | Correct | 444 ms | 908 KB | Output is correct |
15 | Correct | 62 ms | 896 KB | Output is correct |
16 | Correct | 66 ms | 920 KB | Output is correct |
17 | Correct | 111 ms | 1152 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 904 ms | 964 KB | Output is correct |
2 | Correct | 676 ms | 968 KB | Output is correct |
3 | Correct | 605 ms | 896 KB | Output is correct |
4 | Correct | 3 ms | 1096 KB | Output is correct |
5 | Correct | 4 ms | 896 KB | Output is correct |
6 | Correct | 2 ms | 768 KB | Output is correct |
7 | Correct | 584 ms | 968 KB | Output is correct |
8 | Correct | 872 ms | 964 KB | Output is correct |
9 | Correct | 674 ms | 968 KB | Output is correct |
10 | Correct | 592 ms | 976 KB | Output is correct |
11 | Correct | 5 ms | 1152 KB | Output is correct |
12 | Correct | 6 ms | 972 KB | Output is correct |
13 | Correct | 5 ms | 896 KB | Output is correct |
14 | Correct | 3 ms | 768 KB | Output is correct |
15 | Correct | 2 ms | 896 KB | Output is correct |
16 | Correct | 509 ms | 976 KB | Output is correct |
17 | Correct | 571 ms | 1024 KB | Output is correct |
18 | Correct | 567 ms | 928 KB | Output is correct |
19 | Correct | 519 ms | 968 KB | Output is correct |
20 | Correct | 665 ms | 972 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 577 ms | 1024 KB | Output is correct |
2 | Correct | 532 ms | 1140 KB | Output is correct |
3 | Correct | 921 ms | 964 KB | Output is correct |
4 | Correct | 744 ms | 1032 KB | Output is correct |
5 | Correct | 708 ms | 768 KB | Output is correct |
6 | Correct | 466 ms | 1024 KB | Output is correct |
7 | Correct | 490 ms | 1136 KB | Output is correct |
8 | Correct | 3 ms | 972 KB | Output is correct |
9 | Correct | 5 ms | 768 KB | Output is correct |
10 | Correct | 2 ms | 832 KB | Output is correct |
11 | Correct | 598 ms | 1024 KB | Output is correct |
12 | Correct | 579 ms | 900 KB | Output is correct |
13 | Correct | 1081 ms | 968 KB | Output is correct |
14 | Correct | 716 ms | 1096 KB | Output is correct |
15 | Correct | 630 ms | 1024 KB | Output is correct |
16 | Correct | 471 ms | 1024 KB | Output is correct |
17 | Correct | 655 ms | 972 KB | Output is correct |
18 | Correct | 459 ms | 1256 KB | Output is correct |
19 | Correct | 485 ms | 1124 KB | Output is correct |
20 | Correct | 526 ms | 896 KB | Output is correct |
21 | Correct | 62 ms | 768 KB | Output is correct |
22 | Correct | 81 ms | 912 KB | Output is correct |
23 | Correct | 133 ms | 1148 KB | Output is correct |
24 | Correct | 6 ms | 896 KB | Output is correct |
25 | Correct | 7 ms | 768 KB | Output is correct |
26 | Correct | 6 ms | 976 KB | Output is correct |
27 | Correct | 4 ms | 964 KB | Output is correct |
28 | Correct | 1 ms | 896 KB | Output is correct |
29 | Correct | 516 ms | 968 KB | Output is correct |
30 | Correct | 553 ms | 1024 KB | Output is correct |
31 | Correct | 661 ms | 1168 KB | Output is correct |
32 | Correct | 528 ms | 968 KB | Output is correct |
33 | Correct | 510 ms | 972 KB | Output is correct |
34 | Correct | 392 ms | 1024 KB | Output is correct |
35 | Correct | 442 ms | 1264 KB | Output is correct |
36 | Correct | 470 ms | 1120 KB | Output is correct |
37 | Correct | 518 ms | 1136 KB | Output is correct |
38 | Correct | 453 ms | 1248 KB | Output is correct |
39 | Correct | 458 ms | 1116 KB | Output is correct |
40 | Correct | 474 ms | 1136 KB | Output is correct |
41 | Correct | 459 ms | 1248 KB | Output is correct |
42 | Correct | 70 ms | 912 KB | Output is correct |
43 | Correct | 107 ms | 1284 KB | Output is correct |
44 | Correct | 149 ms | 1124 KB | Output is correct |
45 | Correct | 179 ms | 1128 KB | Output is correct |
46 | Correct | 311 ms | 908 KB | Output is correct |
47 | Correct | 327 ms | 1024 KB | Output is correct |
48 | Correct | 69 ms | 1112 KB | Output is correct |
49 | Correct | 63 ms | 1024 KB | Output is correct |