# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
146520 |
2019-08-24T09:49:29 Z |
neki |
Toy Train (IOI17_train) |
C++14 |
|
588 ms |
2552 KB |
#include <bits/stdc++.h>
#include "train.h"
#define loop(i, a, b) for(int i=a;i<b;i++)
#define maxn 20100
using namespace std;
vector<int> ba[maxn], fo[maxn], ans, req, po;
void dfs(int u){loop(i, 0, ba[u].size()){ int v=ba[u][i];req[v]--; if(!req[v] && !po[v]) dfs(v);}};
vector<int> who_wins(vector<int> A, vector<int> C, vector<int> U, vector<int> V){
int n=A.size(), m=U.size();po.resize(n);loop(i, 0, n) po[i]=C[i];
loop(i, 0, m) ba[V[i]].push_back(U[i]), fo[U[i]].push_back(V[i]);
ans.resize(n, 1), req.resize(n);
bool cn=1;
while(cn){
cn=0;
loop(i, 0, n) req[i]=(A[i])? 1:fo[i].size();
loop(i, 0, n) if(po[i]&&ans[i]) dfs(i);
loop(i, 0, n) if(ans[i]!=(req[i]<1)) ans[i]=(req[i]<1), cn=1;
}
return ans;
}
Compilation message
train.cpp: In function 'void dfs(int)':
train.cpp:3:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define loop(i, a, b) for(int i=a;i<b;i++)
train.cpp:8:22:
void dfs(int u){loop(i, 0, ba[u].size()){ int v=ba[u][i];req[v]--; if(!req[v] && !po[v]) dfs(v);}};
~~~~~~~~~~~~~~~~~~
train.cpp:8:17: note: in expansion of macro 'loop'
void dfs(int u){loop(i, 0, ba[u].size()){ int v=ba[u][i];req[v]--; if(!req[v] && !po[v]) dfs(v);}};
^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
1912 KB |
Output is correct |
2 |
Correct |
10 ms |
1912 KB |
Output is correct |
3 |
Correct |
10 ms |
1912 KB |
Output is correct |
4 |
Correct |
11 ms |
1912 KB |
Output is correct |
5 |
Correct |
10 ms |
1912 KB |
Output is correct |
6 |
Correct |
11 ms |
1912 KB |
Output is correct |
7 |
Correct |
9 ms |
1912 KB |
Output is correct |
8 |
Correct |
9 ms |
1912 KB |
Output is correct |
9 |
Correct |
9 ms |
1912 KB |
Output is correct |
10 |
Correct |
8 ms |
1912 KB |
Output is correct |
11 |
Correct |
7 ms |
1912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1272 KB |
Output is correct |
2 |
Correct |
3 ms |
1272 KB |
Output is correct |
3 |
Correct |
3 ms |
1272 KB |
Output is correct |
4 |
Correct |
3 ms |
1192 KB |
Output is correct |
5 |
Correct |
3 ms |
1272 KB |
Output is correct |
6 |
Correct |
3 ms |
1244 KB |
Output is correct |
7 |
Correct |
3 ms |
1272 KB |
Output is correct |
8 |
Correct |
3 ms |
1272 KB |
Output is correct |
9 |
Correct |
4 ms |
1272 KB |
Output is correct |
10 |
Correct |
3 ms |
1272 KB |
Output is correct |
11 |
Correct |
3 ms |
1424 KB |
Output is correct |
12 |
Correct |
3 ms |
1272 KB |
Output is correct |
13 |
Correct |
3 ms |
1272 KB |
Output is correct |
14 |
Correct |
3 ms |
1272 KB |
Output is correct |
15 |
Correct |
3 ms |
1272 KB |
Output is correct |
16 |
Correct |
3 ms |
1272 KB |
Output is correct |
17 |
Correct |
3 ms |
1272 KB |
Output is correct |
18 |
Correct |
3 ms |
1272 KB |
Output is correct |
19 |
Correct |
3 ms |
1272 KB |
Output is correct |
20 |
Correct |
3 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
108 ms |
2552 KB |
Output is correct |
2 |
Correct |
200 ms |
2424 KB |
Output is correct |
3 |
Correct |
295 ms |
2424 KB |
Output is correct |
4 |
Correct |
13 ms |
2424 KB |
Output is correct |
5 |
Correct |
18 ms |
2428 KB |
Output is correct |
6 |
Correct |
14 ms |
2424 KB |
Output is correct |
7 |
Correct |
13 ms |
2340 KB |
Output is correct |
8 |
Correct |
12 ms |
2296 KB |
Output is correct |
9 |
Correct |
11 ms |
2296 KB |
Output is correct |
10 |
Correct |
12 ms |
2296 KB |
Output is correct |
11 |
Correct |
11 ms |
2296 KB |
Output is correct |
12 |
Correct |
11 ms |
2296 KB |
Output is correct |
13 |
Correct |
13 ms |
2424 KB |
Output is correct |
14 |
Correct |
13 ms |
2424 KB |
Output is correct |
15 |
Correct |
13 ms |
2424 KB |
Output is correct |
16 |
Correct |
13 ms |
2424 KB |
Output is correct |
17 |
Correct |
13 ms |
2464 KB |
Output is correct |
18 |
Correct |
355 ms |
2140 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
2168 KB |
Output is correct |
2 |
Correct |
12 ms |
2168 KB |
Output is correct |
3 |
Correct |
12 ms |
2424 KB |
Output is correct |
4 |
Correct |
13 ms |
2296 KB |
Output is correct |
5 |
Correct |
12 ms |
2296 KB |
Output is correct |
6 |
Correct |
13 ms |
2424 KB |
Output is correct |
7 |
Correct |
13 ms |
2296 KB |
Output is correct |
8 |
Correct |
12 ms |
2296 KB |
Output is correct |
9 |
Correct |
13 ms |
2296 KB |
Output is correct |
10 |
Correct |
13 ms |
2296 KB |
Output is correct |
11 |
Correct |
13 ms |
2428 KB |
Output is correct |
12 |
Correct |
12 ms |
2424 KB |
Output is correct |
13 |
Correct |
13 ms |
2296 KB |
Output is correct |
14 |
Correct |
12 ms |
2296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
2296 KB |
Output is correct |
2 |
Correct |
13 ms |
2424 KB |
Output is correct |
3 |
Correct |
13 ms |
2424 KB |
Output is correct |
4 |
Correct |
11 ms |
2300 KB |
Output is correct |
5 |
Correct |
3 ms |
1272 KB |
Output is correct |
6 |
Correct |
7 ms |
1912 KB |
Output is correct |
7 |
Correct |
8 ms |
1912 KB |
Output is correct |
8 |
Correct |
8 ms |
2040 KB |
Output is correct |
9 |
Correct |
8 ms |
2040 KB |
Output is correct |
10 |
Correct |
4 ms |
1528 KB |
Output is correct |
11 |
Correct |
8 ms |
1912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
1912 KB |
Output is correct |
2 |
Correct |
10 ms |
1912 KB |
Output is correct |
3 |
Correct |
10 ms |
1912 KB |
Output is correct |
4 |
Correct |
11 ms |
1912 KB |
Output is correct |
5 |
Correct |
10 ms |
1912 KB |
Output is correct |
6 |
Correct |
11 ms |
1912 KB |
Output is correct |
7 |
Correct |
9 ms |
1912 KB |
Output is correct |
8 |
Correct |
9 ms |
1912 KB |
Output is correct |
9 |
Correct |
9 ms |
1912 KB |
Output is correct |
10 |
Correct |
8 ms |
1912 KB |
Output is correct |
11 |
Correct |
7 ms |
1912 KB |
Output is correct |
12 |
Correct |
3 ms |
1272 KB |
Output is correct |
13 |
Correct |
3 ms |
1272 KB |
Output is correct |
14 |
Correct |
3 ms |
1272 KB |
Output is correct |
15 |
Correct |
3 ms |
1192 KB |
Output is correct |
16 |
Correct |
3 ms |
1272 KB |
Output is correct |
17 |
Correct |
3 ms |
1244 KB |
Output is correct |
18 |
Correct |
3 ms |
1272 KB |
Output is correct |
19 |
Correct |
3 ms |
1272 KB |
Output is correct |
20 |
Correct |
4 ms |
1272 KB |
Output is correct |
21 |
Correct |
3 ms |
1272 KB |
Output is correct |
22 |
Correct |
3 ms |
1424 KB |
Output is correct |
23 |
Correct |
3 ms |
1272 KB |
Output is correct |
24 |
Correct |
3 ms |
1272 KB |
Output is correct |
25 |
Correct |
3 ms |
1272 KB |
Output is correct |
26 |
Correct |
3 ms |
1272 KB |
Output is correct |
27 |
Correct |
3 ms |
1272 KB |
Output is correct |
28 |
Correct |
3 ms |
1272 KB |
Output is correct |
29 |
Correct |
3 ms |
1272 KB |
Output is correct |
30 |
Correct |
3 ms |
1272 KB |
Output is correct |
31 |
Correct |
3 ms |
1272 KB |
Output is correct |
32 |
Correct |
108 ms |
2552 KB |
Output is correct |
33 |
Correct |
200 ms |
2424 KB |
Output is correct |
34 |
Correct |
295 ms |
2424 KB |
Output is correct |
35 |
Correct |
13 ms |
2424 KB |
Output is correct |
36 |
Correct |
18 ms |
2428 KB |
Output is correct |
37 |
Correct |
14 ms |
2424 KB |
Output is correct |
38 |
Correct |
13 ms |
2340 KB |
Output is correct |
39 |
Correct |
12 ms |
2296 KB |
Output is correct |
40 |
Correct |
11 ms |
2296 KB |
Output is correct |
41 |
Correct |
12 ms |
2296 KB |
Output is correct |
42 |
Correct |
11 ms |
2296 KB |
Output is correct |
43 |
Correct |
11 ms |
2296 KB |
Output is correct |
44 |
Correct |
13 ms |
2424 KB |
Output is correct |
45 |
Correct |
13 ms |
2424 KB |
Output is correct |
46 |
Correct |
13 ms |
2424 KB |
Output is correct |
47 |
Correct |
13 ms |
2424 KB |
Output is correct |
48 |
Correct |
13 ms |
2464 KB |
Output is correct |
49 |
Correct |
355 ms |
2140 KB |
Output is correct |
50 |
Correct |
12 ms |
2168 KB |
Output is correct |
51 |
Correct |
12 ms |
2168 KB |
Output is correct |
52 |
Correct |
12 ms |
2424 KB |
Output is correct |
53 |
Correct |
13 ms |
2296 KB |
Output is correct |
54 |
Correct |
12 ms |
2296 KB |
Output is correct |
55 |
Correct |
13 ms |
2424 KB |
Output is correct |
56 |
Correct |
13 ms |
2296 KB |
Output is correct |
57 |
Correct |
12 ms |
2296 KB |
Output is correct |
58 |
Correct |
13 ms |
2296 KB |
Output is correct |
59 |
Correct |
13 ms |
2296 KB |
Output is correct |
60 |
Correct |
13 ms |
2428 KB |
Output is correct |
61 |
Correct |
12 ms |
2424 KB |
Output is correct |
62 |
Correct |
13 ms |
2296 KB |
Output is correct |
63 |
Correct |
12 ms |
2296 KB |
Output is correct |
64 |
Correct |
13 ms |
2296 KB |
Output is correct |
65 |
Correct |
13 ms |
2424 KB |
Output is correct |
66 |
Correct |
13 ms |
2424 KB |
Output is correct |
67 |
Correct |
11 ms |
2300 KB |
Output is correct |
68 |
Correct |
3 ms |
1272 KB |
Output is correct |
69 |
Correct |
7 ms |
1912 KB |
Output is correct |
70 |
Correct |
8 ms |
1912 KB |
Output is correct |
71 |
Correct |
8 ms |
2040 KB |
Output is correct |
72 |
Correct |
8 ms |
2040 KB |
Output is correct |
73 |
Correct |
4 ms |
1528 KB |
Output is correct |
74 |
Correct |
8 ms |
1912 KB |
Output is correct |
75 |
Correct |
149 ms |
2448 KB |
Output is correct |
76 |
Correct |
227 ms |
2424 KB |
Output is correct |
77 |
Correct |
333 ms |
2424 KB |
Output is correct |
78 |
Correct |
328 ms |
2524 KB |
Output is correct |
79 |
Correct |
336 ms |
2420 KB |
Output is correct |
80 |
Correct |
14 ms |
2424 KB |
Output is correct |
81 |
Correct |
14 ms |
2296 KB |
Output is correct |
82 |
Correct |
14 ms |
2296 KB |
Output is correct |
83 |
Correct |
18 ms |
2424 KB |
Output is correct |
84 |
Correct |
17 ms |
2424 KB |
Output is correct |
85 |
Correct |
14 ms |
2296 KB |
Output is correct |
86 |
Correct |
18 ms |
2424 KB |
Output is correct |
87 |
Correct |
13 ms |
2300 KB |
Output is correct |
88 |
Correct |
20 ms |
2296 KB |
Output is correct |
89 |
Correct |
14 ms |
2296 KB |
Output is correct |
90 |
Correct |
26 ms |
2396 KB |
Output is correct |
91 |
Correct |
29 ms |
2296 KB |
Output is correct |
92 |
Correct |
49 ms |
2424 KB |
Output is correct |
93 |
Correct |
39 ms |
2296 KB |
Output is correct |
94 |
Correct |
41 ms |
2296 KB |
Output is correct |
95 |
Correct |
44 ms |
2424 KB |
Output is correct |
96 |
Correct |
91 ms |
2296 KB |
Output is correct |
97 |
Correct |
347 ms |
2380 KB |
Output is correct |
98 |
Correct |
543 ms |
2468 KB |
Output is correct |
99 |
Correct |
588 ms |
2316 KB |
Output is correct |
100 |
Correct |
348 ms |
2040 KB |
Output is correct |