# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
349982 | 2021-01-18T19:21:20 Z | evn | 기지국 (IOI20_stations) | C++14 | 1126 ms | 1616 KB |
#include <bits/stdc++.h> #include "stations.h" using namespace std; #define f first #define s second #define pb push_back #define mp make_pair #define sz(a) a.size() typedef long long ll; typedef pair<int, int> pii; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; int timer = 0; int depth[1005]; int in[1005]; int out[1005]; vector<int> adj[1005]; vector<int> labels; void dfs(int u, int p){ in[u] = timer++; for(int v : adj[u]){ if(v != p){ depth[v] = depth[u]+1; dfs(v, u); } } out[u] = timer++; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { labels.resize(n); for(int i = 0; i < n;i ++){ adj[i].clear(); depth[i] = 0; labels[i] = 0; } for(int i = 0; i < u.size(); i++){ int a, b; a = u[i]; b = v[i]; adj[a].pb(b); adj[b].pb(a); } dfs(0, -1); vector<int> times; for(int i = 0; i < n;i ++){ if(depth[i] % 2 == 0){ times.pb(in[i]); } else{ times.pb(out[i]); } } sort(times.begin(), times.end()); map<int, int> x; int curr = 0; for(int i = 0; i < n;i ++){ x[times[i]]=curr++; } for(int i = 0; i< n;i ++){ int lbl =0; if(depth[i] % 2 ==0){ lbl = x[in[i]]; } else{ lbl = x[out[i]]; } labels[i] = lbl; } return labels; } int find_next_station(int s, int t, vector<int> c) { if(c.size() == 1)return c[0]; if(c[0] > s){ //this is the in value if(t < s || t >= c[c.size()-1])return c[c.size()-1]; for(int i = 0;i < c.size()-1; i++){ if(t <= c[i])return c[i]; } } else{ //this is the out value if(t <= c[0] || t > s)return c[0]; for(int i = c.size()-1; i >= 1; i--){ if(t >= c[i])return c[i]; } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 649 ms | 1028 KB | Output is correct |
2 | Correct | 473 ms | 992 KB | Output is correct |
3 | Correct | 1039 ms | 948 KB | Output is correct |
4 | Correct | 775 ms | 948 KB | Output is correct |
5 | Correct | 577 ms | 864 KB | Output is correct |
6 | Correct | 555 ms | 1032 KB | Output is correct |
7 | Correct | 474 ms | 1048 KB | Output is correct |
8 | Correct | 3 ms | 948 KB | Output is correct |
9 | Correct | 5 ms | 904 KB | Output is correct |
10 | Correct | 2 ms | 864 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 517 ms | 1080 KB | Output is correct |
2 | Correct | 686 ms | 1144 KB | Output is correct |
3 | Correct | 1067 ms | 940 KB | Output is correct |
4 | Correct | 801 ms | 940 KB | Output is correct |
5 | Correct | 613 ms | 1108 KB | Output is correct |
6 | Correct | 461 ms | 1088 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 588 ms | 992 KB | Output is correct |
2 | Correct | 524 ms | 992 KB | Output is correct |
3 | Correct | 966 ms | 940 KB | Output is correct |
4 | Correct | 750 ms | 864 KB | Output is correct |
5 | Correct | 622 ms | 736 KB | Output is correct |
6 | Correct | 581 ms | 992 KB | Output is correct |
7 | Correct | 575 ms | 864 KB | Output is correct |
8 | Correct | 3 ms | 864 KB | Output is correct |
9 | Correct | 4 ms | 940 KB | Output is correct |
10 | Correct | 2 ms | 736 KB | Output is correct |
11 | Correct | 692 ms | 864 KB | Output is correct |
12 | Correct | 538 ms | 1280 KB | Output is correct |
13 | Correct | 482 ms | 1152 KB | Output is correct |
14 | Correct | 510 ms | 1088 KB | Output is correct |
15 | Correct | 52 ms | 936 KB | Output is correct |
16 | Correct | 63 ms | 872 KB | Output is correct |
17 | Correct | 132 ms | 1096 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 959 ms | 864 KB | Output is correct |
2 | Correct | 654 ms | 736 KB | Output is correct |
3 | Correct | 634 ms | 736 KB | Output is correct |
4 | Correct | 3 ms | 988 KB | Output is correct |
5 | Correct | 5 ms | 736 KB | Output is correct |
6 | Correct | 2 ms | 864 KB | Output is correct |
7 | Correct | 651 ms | 864 KB | Output is correct |
8 | Correct | 974 ms | 736 KB | Output is correct |
9 | Correct | 826 ms | 940 KB | Output is correct |
10 | Correct | 603 ms | 940 KB | Output is correct |
11 | Correct | 5 ms | 940 KB | Output is correct |
12 | Correct | 7 ms | 736 KB | Output is correct |
13 | Correct | 6 ms | 736 KB | Output is correct |
14 | Correct | 4 ms | 948 KB | Output is correct |
15 | Correct | 2 ms | 736 KB | Output is correct |
16 | Correct | 618 ms | 864 KB | Output is correct |
17 | Correct | 468 ms | 864 KB | Output is correct |
18 | Correct | 586 ms | 1068 KB | Output is correct |
19 | Correct | 478 ms | 736 KB | Output is correct |
20 | Correct | 497 ms | 940 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 534 ms | 1032 KB | Output is correct |
2 | Correct | 504 ms | 1028 KB | Output is correct |
3 | Correct | 1005 ms | 1068 KB | Output is correct |
4 | Correct | 759 ms | 940 KB | Output is correct |
5 | Correct | 597 ms | 864 KB | Output is correct |
6 | Correct | 490 ms | 992 KB | Output is correct |
7 | Correct | 520 ms | 1056 KB | Output is correct |
8 | Correct | 3 ms | 940 KB | Output is correct |
9 | Correct | 5 ms | 736 KB | Output is correct |
10 | Correct | 2 ms | 864 KB | Output is correct |
11 | Correct | 545 ms | 1120 KB | Output is correct |
12 | Correct | 553 ms | 1080 KB | Output is correct |
13 | Correct | 1126 ms | 992 KB | Output is correct |
14 | Correct | 689 ms | 940 KB | Output is correct |
15 | Correct | 719 ms | 940 KB | Output is correct |
16 | Correct | 531 ms | 992 KB | Output is correct |
17 | Correct | 709 ms | 940 KB | Output is correct |
18 | Correct | 567 ms | 1060 KB | Output is correct |
19 | Correct | 550 ms | 1616 KB | Output is correct |
20 | Correct | 449 ms | 1088 KB | Output is correct |
21 | Correct | 68 ms | 928 KB | Output is correct |
22 | Correct | 80 ms | 736 KB | Output is correct |
23 | Correct | 149 ms | 864 KB | Output is correct |
24 | Correct | 6 ms | 940 KB | Output is correct |
25 | Correct | 6 ms | 948 KB | Output is correct |
26 | Correct | 5 ms | 940 KB | Output is correct |
27 | Correct | 4 ms | 948 KB | Output is correct |
28 | Correct | 2 ms | 736 KB | Output is correct |
29 | Correct | 576 ms | 864 KB | Output is correct |
30 | Correct | 658 ms | 736 KB | Output is correct |
31 | Correct | 630 ms | 736 KB | Output is correct |
32 | Correct | 553 ms | 940 KB | Output is correct |
33 | Correct | 548 ms | 1196 KB | Output is correct |
34 | Correct | 393 ms | 1036 KB | Output is correct |
35 | Correct | 464 ms | 992 KB | Output is correct |
36 | Correct | 442 ms | 992 KB | Output is correct |
37 | Correct | 545 ms | 864 KB | Output is correct |
38 | Correct | 486 ms | 1008 KB | Output is correct |
39 | Correct | 521 ms | 1084 KB | Output is correct |
40 | Correct | 589 ms | 1056 KB | Output is correct |
41 | Correct | 519 ms | 864 KB | Output is correct |
42 | Correct | 66 ms | 1104 KB | Output is correct |
43 | Correct | 113 ms | 864 KB | Output is correct |
44 | Correct | 144 ms | 1064 KB | Output is correct |
45 | Correct | 172 ms | 992 KB | Output is correct |
46 | Correct | 420 ms | 992 KB | Output is correct |
47 | Correct | 428 ms | 992 KB | Output is correct |
48 | Correct | 93 ms | 932 KB | Output is correct |
49 | Correct | 79 ms | 1080 KB | Output is correct |