# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
321227 | 2020-11-11T15:29:32 Z | giorgikob | Stations (IOI20_stations) | C++14 | 1093 ms | 1248 KB |
#include "stations.h" #include <vector> #include<bits/stdc++.h> #define ll long long #define ff first #define ss second #define pb push_back using namespace std; const int N = 1e3+5; vector<int>gr[N]; int cnt = 0; int fix[N]; int mn[N]; int in[N], out[N]; vector<pair<int,int>>P; void dfs(int x, int h, vector<int>&v){ fix[x] = 1; in[x] = cnt;cnt++; for(auto to : gr[x]){ if(fix[to]) continue; dfs(to,h+1,v); } out[x] = cnt;cnt++; if(h%2){ //v[x] = out[x]; P.pb({out[x],x}); } else { //v[x] = in[x]; P.pb({in[x],x}); } } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { std::vector<int> labels(n,0); for(int i = 0; i < u.size(); i++){ int x = u[i]; int y = v[i]; gr[x].pb(y); gr[y].pb(x); } cnt = 0; dfs(0,0,labels); sort(P.begin(),P.end()); for(int i = 0; i < P.size(); i++){ labels[P[i].ss] = i; } P.clear(); for(int i = 0; i < n; i++) gr[i].clear(), fix[i] = 0; return labels; } int find_next_station(int s, int t, std::vector<int> c) { /*cout << "test case" << endl; cout << s << " " << t << endl; for(auto x : c) cout << x << " "; cout << endl; cout << "end of test case" << endl; */ if(c.size() == 1) return c[0]; if(c[0] < s){ for(int i = 1; i < c.size(); i++){ int in = c[i]; int out = (c[i] == c.back()) ? (s-1) : (c[i+1] - 1); if(in <= t && t <= out) return c[i]; } return c[0]; } else { for(int i = 0; i < c.size() - 1; i++){ int in = (i == 0) ? (s + 1) : (c[i-1] + 1); int out = c[i]; if(in <= t && t <= out) return c[i]; } return c.back(); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 581 ms | 1024 KB | Output is correct |
2 | Correct | 442 ms | 1028 KB | Output is correct |
3 | Correct | 1039 ms | 940 KB | Output is correct |
4 | Correct | 703 ms | 688 KB | Output is correct |
5 | Correct | 689 ms | 992 KB | Output is correct |
6 | Correct | 530 ms | 992 KB | Output is correct |
7 | Correct | 471 ms | 1152 KB | Output is correct |
8 | Correct | 3 ms | 736 KB | Output is correct |
9 | Correct | 6 ms | 736 KB | Output is correct |
10 | Correct | 2 ms | 948 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 537 ms | 864 KB | Output is correct |
2 | Correct | 575 ms | 1116 KB | Output is correct |
3 | Correct | 876 ms | 736 KB | Output is correct |
4 | Correct | 704 ms | 736 KB | Output is correct |
5 | Correct | 692 ms | 824 KB | Output is correct |
6 | Correct | 451 ms | 868 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 513 ms | 1048 KB | Output is correct |
2 | Correct | 436 ms | 992 KB | Output is correct |
3 | Correct | 1035 ms | 940 KB | Output is correct |
4 | Correct | 664 ms | 940 KB | Output is correct |
5 | Correct | 660 ms | 1120 KB | Output is correct |
6 | Correct | 482 ms | 1040 KB | Output is correct |
7 | Correct | 454 ms | 948 KB | Output is correct |
8 | Correct | 3 ms | 736 KB | Output is correct |
9 | Correct | 5 ms | 948 KB | Output is correct |
10 | Correct | 1 ms | 768 KB | Output is correct |
11 | Correct | 548 ms | 900 KB | Output is correct |
12 | Correct | 437 ms | 1116 KB | Output is correct |
13 | Correct | 472 ms | 1048 KB | Output is correct |
14 | Correct | 506 ms | 992 KB | Output is correct |
15 | Correct | 51 ms | 864 KB | Output is correct |
16 | Correct | 64 ms | 736 KB | Output is correct |
17 | Correct | 112 ms | 992 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 933 ms | 936 KB | Output is correct |
2 | Correct | 766 ms | 864 KB | Output is correct |
3 | Correct | 650 ms | 968 KB | Output is correct |
4 | Correct | 3 ms | 1244 KB | Output is correct |
5 | Correct | 5 ms | 940 KB | Output is correct |
6 | Correct | 2 ms | 864 KB | Output is correct |
7 | Correct | 649 ms | 944 KB | Output is correct |
8 | Correct | 1093 ms | 992 KB | Output is correct |
9 | Correct | 788 ms | 932 KB | Output is correct |
10 | Correct | 604 ms | 864 KB | Output is correct |
11 | Correct | 7 ms | 736 KB | Output is correct |
12 | Correct | 7 ms | 900 KB | Output is correct |
13 | Correct | 5 ms | 736 KB | Output is correct |
14 | Correct | 3 ms | 736 KB | Output is correct |
15 | Correct | 3 ms | 864 KB | Output is correct |
16 | Correct | 656 ms | 944 KB | Output is correct |
17 | Correct | 511 ms | 992 KB | Output is correct |
18 | Correct | 587 ms | 936 KB | Output is correct |
19 | Correct | 643 ms | 864 KB | Output is correct |
20 | Correct | 557 ms | 944 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 541 ms | 992 KB | Output is correct |
2 | Correct | 445 ms | 992 KB | Output is correct |
3 | Correct | 873 ms | 932 KB | Output is correct |
4 | Correct | 611 ms | 736 KB | Output is correct |
5 | Correct | 611 ms | 864 KB | Output is correct |
6 | Correct | 453 ms | 864 KB | Output is correct |
7 | Correct | 490 ms | 1076 KB | Output is correct |
8 | Correct | 3 ms | 944 KB | Output is correct |
9 | Correct | 5 ms | 736 KB | Output is correct |
10 | Correct | 2 ms | 736 KB | Output is correct |
11 | Correct | 512 ms | 736 KB | Output is correct |
12 | Correct | 528 ms | 924 KB | Output is correct |
13 | Correct | 882 ms | 864 KB | Output is correct |
14 | Correct | 657 ms | 936 KB | Output is correct |
15 | Correct | 616 ms | 936 KB | Output is correct |
16 | Correct | 540 ms | 872 KB | Output is correct |
17 | Correct | 719 ms | 936 KB | Output is correct |
18 | Correct | 470 ms | 1184 KB | Output is correct |
19 | Correct | 490 ms | 1160 KB | Output is correct |
20 | Correct | 526 ms | 864 KB | Output is correct |
21 | Correct | 63 ms | 940 KB | Output is correct |
22 | Correct | 84 ms | 736 KB | Output is correct |
23 | Correct | 112 ms | 872 KB | Output is correct |
24 | Correct | 7 ms | 948 KB | Output is correct |
25 | Correct | 7 ms | 736 KB | Output is correct |
26 | Correct | 5 ms | 936 KB | Output is correct |
27 | Correct | 3 ms | 948 KB | Output is correct |
28 | Correct | 2 ms | 736 KB | Output is correct |
29 | Correct | 530 ms | 736 KB | Output is correct |
30 | Correct | 545 ms | 736 KB | Output is correct |
31 | Correct | 585 ms | 936 KB | Output is correct |
32 | Correct | 544 ms | 940 KB | Output is correct |
33 | Correct | 575 ms | 1020 KB | Output is correct |
34 | Correct | 351 ms | 1056 KB | Output is correct |
35 | Correct | 419 ms | 992 KB | Output is correct |
36 | Correct | 567 ms | 1036 KB | Output is correct |
37 | Correct | 511 ms | 1192 KB | Output is correct |
38 | Correct | 438 ms | 1092 KB | Output is correct |
39 | Correct | 491 ms | 1116 KB | Output is correct |
40 | Correct | 590 ms | 1072 KB | Output is correct |
41 | Correct | 572 ms | 1112 KB | Output is correct |
42 | Correct | 75 ms | 1024 KB | Output is correct |
43 | Correct | 143 ms | 736 KB | Output is correct |
44 | Correct | 119 ms | 864 KB | Output is correct |
45 | Correct | 177 ms | 992 KB | Output is correct |
46 | Correct | 338 ms | 1000 KB | Output is correct |
47 | Correct | 327 ms | 1020 KB | Output is correct |
48 | Correct | 80 ms | 1248 KB | Output is correct |
49 | Correct | 74 ms | 1072 KB | Output is correct |