# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
58642 | 2018-07-18T14:42:27 Z | reality | Toy Train (IOI17_train) | C++17 | 609 ms | 36356 KB |
#include "bits/stdc++.h" using namespace std; #define fi first #define se second #define ll long long #define dbg(v) cerr<<#v<<" = "<<v<<'\n' #define vi vector<int> #define vl vector <ll> #define pii pair<int,int> #define mp make_pair #define db long double #define pb push_back #define all(s) s.begin(),s.end() template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;} template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;} #include "train.h" vi answer; int n; const int N = 1e6; vi G[N]; int deg[N]; int d[N]; vi who; void dfs(int node) { for (auto it : G[node]) { --deg[it]; if (!deg[it] && who[it]) dfs(it); } } vi who_wins(vi a, vi b, vi u, vi v) { n = a.size(); for (auto & it : b) it ^= 1; who = b; for (int i = 0;i < u.size();++i) G[v[i]].pb(u[i]),++d[u[i]]; answer.resize(n); for (int i = 0;i < n;++i) answer[i] = 1; int ok; do { ok = 0; who = b; for (int i = 0;i < n;++i) deg[i] = a[i] ? 1 : d[i]; for (int i = 0;i < n;++i) if (!who[i] && answer[i]) dfs(i); for (int i = 0;i < n;++i) { if (!who[i] && answer[i] && deg[i] > 0) ok = 1,answer[i] = 0; } } while (ok); for (int i = 0;i < n;++i) answer[i] &= deg[i] <= 0; return answer; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 43 ms | 24184 KB | Output is correct |
2 | Correct | 36 ms | 24548 KB | Output is correct |
3 | Correct | 41 ms | 24616 KB | Output is correct |
4 | Correct | 33 ms | 24824 KB | Output is correct |
5 | Correct | 35 ms | 24968 KB | Output is correct |
6 | Correct | 33 ms | 24968 KB | Output is correct |
7 | Correct | 30 ms | 25140 KB | Output is correct |
8 | Correct | 28 ms | 25160 KB | Output is correct |
9 | Correct | 37 ms | 25244 KB | Output is correct |
10 | Correct | 33 ms | 25324 KB | Output is correct |
11 | Correct | 31 ms | 25404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 25404 KB | Output is correct |
2 | Correct | 25 ms | 25404 KB | Output is correct |
3 | Correct | 24 ms | 25404 KB | Output is correct |
4 | Correct | 28 ms | 25404 KB | Output is correct |
5 | Correct | 28 ms | 25404 KB | Output is correct |
6 | Correct | 30 ms | 25404 KB | Output is correct |
7 | Correct | 26 ms | 25404 KB | Output is correct |
8 | Correct | 26 ms | 25404 KB | Output is correct |
9 | Correct | 24 ms | 25404 KB | Output is correct |
10 | Correct | 27 ms | 25404 KB | Output is correct |
11 | Correct | 24 ms | 25404 KB | Output is correct |
12 | Correct | 24 ms | 25404 KB | Output is correct |
13 | Correct | 26 ms | 25404 KB | Output is correct |
14 | Correct | 24 ms | 25404 KB | Output is correct |
15 | Correct | 25 ms | 25404 KB | Output is correct |
16 | Correct | 24 ms | 25404 KB | Output is correct |
17 | Correct | 27 ms | 25404 KB | Output is correct |
18 | Correct | 30 ms | 25404 KB | Output is correct |
19 | Correct | 27 ms | 25404 KB | Output is correct |
20 | Correct | 26 ms | 25404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 111 ms | 25968 KB | Output is correct |
2 | Correct | 202 ms | 26132 KB | Output is correct |
3 | Correct | 237 ms | 26404 KB | Output is correct |
4 | Correct | 33 ms | 26408 KB | Output is correct |
5 | Correct | 44 ms | 26744 KB | Output is correct |
6 | Correct | 36 ms | 26824 KB | Output is correct |
7 | Correct | 40 ms | 27032 KB | Output is correct |
8 | Correct | 33 ms | 27284 KB | Output is correct |
9 | Correct | 34 ms | 27448 KB | Output is correct |
10 | Correct | 47 ms | 27616 KB | Output is correct |
11 | Correct | 43 ms | 27896 KB | Output is correct |
12 | Correct | 42 ms | 27904 KB | Output is correct |
13 | Correct | 33 ms | 28340 KB | Output is correct |
14 | Correct | 38 ms | 28620 KB | Output is correct |
15 | Correct | 43 ms | 28828 KB | Output is correct |
16 | Correct | 37 ms | 28972 KB | Output is correct |
17 | Correct | 31 ms | 29172 KB | Output is correct |
18 | Correct | 318 ms | 29172 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 31 ms | 29172 KB | Output is correct |
2 | Correct | 32 ms | 29240 KB | Output is correct |
3 | Correct | 34 ms | 29576 KB | Output is correct |
4 | Correct | 35 ms | 29884 KB | Output is correct |
5 | Correct | 34 ms | 29964 KB | Output is correct |
6 | Correct | 34 ms | 30168 KB | Output is correct |
7 | Correct | 33 ms | 30496 KB | Output is correct |
8 | Correct | 40 ms | 30568 KB | Output is correct |
9 | Correct | 33 ms | 30764 KB | Output is correct |
10 | Correct | 34 ms | 31112 KB | Output is correct |
11 | Correct | 39 ms | 31112 KB | Output is correct |
12 | Correct | 37 ms | 31112 KB | Output is correct |
13 | Correct | 36 ms | 31112 KB | Output is correct |
14 | Correct | 32 ms | 31112 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 31112 KB | Output is correct |
2 | Correct | 39 ms | 31112 KB | Output is correct |
3 | Correct | 34 ms | 31112 KB | Output is correct |
4 | Correct | 31 ms | 31112 KB | Output is correct |
5 | Correct | 27 ms | 31112 KB | Output is correct |
6 | Correct | 33 ms | 31112 KB | Output is correct |
7 | Correct | 32 ms | 31112 KB | Output is correct |
8 | Correct | 31 ms | 31112 KB | Output is correct |
9 | Correct | 41 ms | 31112 KB | Output is correct |
10 | Correct | 26 ms | 31112 KB | Output is correct |
11 | Correct | 36 ms | 31112 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 43 ms | 24184 KB | Output is correct |
2 | Correct | 36 ms | 24548 KB | Output is correct |
3 | Correct | 41 ms | 24616 KB | Output is correct |
4 | Correct | 33 ms | 24824 KB | Output is correct |
5 | Correct | 35 ms | 24968 KB | Output is correct |
6 | Correct | 33 ms | 24968 KB | Output is correct |
7 | Correct | 30 ms | 25140 KB | Output is correct |
8 | Correct | 28 ms | 25160 KB | Output is correct |
9 | Correct | 37 ms | 25244 KB | Output is correct |
10 | Correct | 33 ms | 25324 KB | Output is correct |
11 | Correct | 31 ms | 25404 KB | Output is correct |
12 | Correct | 27 ms | 25404 KB | Output is correct |
13 | Correct | 25 ms | 25404 KB | Output is correct |
14 | Correct | 24 ms | 25404 KB | Output is correct |
15 | Correct | 28 ms | 25404 KB | Output is correct |
16 | Correct | 28 ms | 25404 KB | Output is correct |
17 | Correct | 30 ms | 25404 KB | Output is correct |
18 | Correct | 26 ms | 25404 KB | Output is correct |
19 | Correct | 26 ms | 25404 KB | Output is correct |
20 | Correct | 24 ms | 25404 KB | Output is correct |
21 | Correct | 27 ms | 25404 KB | Output is correct |
22 | Correct | 24 ms | 25404 KB | Output is correct |
23 | Correct | 24 ms | 25404 KB | Output is correct |
24 | Correct | 26 ms | 25404 KB | Output is correct |
25 | Correct | 24 ms | 25404 KB | Output is correct |
26 | Correct | 25 ms | 25404 KB | Output is correct |
27 | Correct | 24 ms | 25404 KB | Output is correct |
28 | Correct | 27 ms | 25404 KB | Output is correct |
29 | Correct | 30 ms | 25404 KB | Output is correct |
30 | Correct | 27 ms | 25404 KB | Output is correct |
31 | Correct | 26 ms | 25404 KB | Output is correct |
32 | Correct | 111 ms | 25968 KB | Output is correct |
33 | Correct | 202 ms | 26132 KB | Output is correct |
34 | Correct | 237 ms | 26404 KB | Output is correct |
35 | Correct | 33 ms | 26408 KB | Output is correct |
36 | Correct | 44 ms | 26744 KB | Output is correct |
37 | Correct | 36 ms | 26824 KB | Output is correct |
38 | Correct | 40 ms | 27032 KB | Output is correct |
39 | Correct | 33 ms | 27284 KB | Output is correct |
40 | Correct | 34 ms | 27448 KB | Output is correct |
41 | Correct | 47 ms | 27616 KB | Output is correct |
42 | Correct | 43 ms | 27896 KB | Output is correct |
43 | Correct | 42 ms | 27904 KB | Output is correct |
44 | Correct | 33 ms | 28340 KB | Output is correct |
45 | Correct | 38 ms | 28620 KB | Output is correct |
46 | Correct | 43 ms | 28828 KB | Output is correct |
47 | Correct | 37 ms | 28972 KB | Output is correct |
48 | Correct | 31 ms | 29172 KB | Output is correct |
49 | Correct | 318 ms | 29172 KB | Output is correct |
50 | Correct | 31 ms | 29172 KB | Output is correct |
51 | Correct | 32 ms | 29240 KB | Output is correct |
52 | Correct | 34 ms | 29576 KB | Output is correct |
53 | Correct | 35 ms | 29884 KB | Output is correct |
54 | Correct | 34 ms | 29964 KB | Output is correct |
55 | Correct | 34 ms | 30168 KB | Output is correct |
56 | Correct | 33 ms | 30496 KB | Output is correct |
57 | Correct | 40 ms | 30568 KB | Output is correct |
58 | Correct | 33 ms | 30764 KB | Output is correct |
59 | Correct | 34 ms | 31112 KB | Output is correct |
60 | Correct | 39 ms | 31112 KB | Output is correct |
61 | Correct | 37 ms | 31112 KB | Output is correct |
62 | Correct | 36 ms | 31112 KB | Output is correct |
63 | Correct | 32 ms | 31112 KB | Output is correct |
64 | Correct | 32 ms | 31112 KB | Output is correct |
65 | Correct | 39 ms | 31112 KB | Output is correct |
66 | Correct | 34 ms | 31112 KB | Output is correct |
67 | Correct | 31 ms | 31112 KB | Output is correct |
68 | Correct | 27 ms | 31112 KB | Output is correct |
69 | Correct | 33 ms | 31112 KB | Output is correct |
70 | Correct | 32 ms | 31112 KB | Output is correct |
71 | Correct | 31 ms | 31112 KB | Output is correct |
72 | Correct | 41 ms | 31112 KB | Output is correct |
73 | Correct | 26 ms | 31112 KB | Output is correct |
74 | Correct | 36 ms | 31112 KB | Output is correct |
75 | Correct | 103 ms | 31556 KB | Output is correct |
76 | Correct | 213 ms | 31732 KB | Output is correct |
77 | Correct | 281 ms | 31936 KB | Output is correct |
78 | Correct | 245 ms | 32144 KB | Output is correct |
79 | Correct | 273 ms | 32324 KB | Output is correct |
80 | Correct | 40 ms | 32432 KB | Output is correct |
81 | Correct | 42 ms | 32820 KB | Output is correct |
82 | Correct | 41 ms | 32848 KB | Output is correct |
83 | Correct | 35 ms | 33184 KB | Output is correct |
84 | Correct | 37 ms | 33380 KB | Output is correct |
85 | Correct | 34 ms | 33432 KB | Output is correct |
86 | Correct | 48 ms | 33752 KB | Output is correct |
87 | Correct | 32 ms | 33888 KB | Output is correct |
88 | Correct | 53 ms | 34096 KB | Output is correct |
89 | Correct | 47 ms | 34304 KB | Output is correct |
90 | Correct | 48 ms | 34640 KB | Output is correct |
91 | Correct | 64 ms | 34720 KB | Output is correct |
92 | Correct | 63 ms | 35056 KB | Output is correct |
93 | Correct | 53 ms | 35136 KB | Output is correct |
94 | Correct | 67 ms | 35472 KB | Output is correct |
95 | Correct | 65 ms | 35684 KB | Output is correct |
96 | Correct | 91 ms | 35684 KB | Output is correct |
97 | Correct | 358 ms | 36076 KB | Output is correct |
98 | Correct | 539 ms | 36156 KB | Output is correct |
99 | Correct | 609 ms | 36356 KB | Output is correct |
100 | Correct | 383 ms | 36356 KB | Output is correct |