# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
287600 |
2020-08-31T20:57:31 Z |
evpipis |
Toy Train (IOI17_train) |
C++11 |
|
1008 ms |
1552 KB |
#include <bits/stdc++.h>
#include "train.h"
using namespace std;
#define pb push_back
typedef vector<int> vi;
const int len = 5005;
int vis[len], block[len], bel[len], deg[len], n;
vector<int> adj[len];
vi operator-(vi a, vi b){
sort(a.begin(), a.end());
sort(b.begin(), b.end());
vi res;
for (int i = 0, j = 0; i < a.size(); i++){
while (j < b.size() && b[j] < a[i])
j++;
if (j == b.size() || b[j] > a[i])
res.pb(a[i]);
}
return res;
}
vi func(int sub, vi base){
for (int u = 0; u < n; u++)
vis[u] = deg[u] = 0;
for (int u = 0; u < n; u++){
if (block[u]) continue;
for (auto v: adj[u])
if (!block[v])
deg[v]++;
}
queue<int> myq;
for (auto u: base)
vis[u] = 1, myq.push(u);
while (!myq.empty()){
int u = myq.front();
myq.pop();
for (auto v: adj[u]){
if (block[v] || vis[v])
continue;
if (bel[v] == sub)
vis[v] = 1, myq.push(v);
else{
deg[v]--;
if (!deg[v])
vis[v] = 1, myq.push(v);
}
}
}
vi res;
for (int i = 0; i < n; i++)
if (!block[i] && vis[i])
res.pb(i);
return res;
}
vi who_wins(vi B, vi spec, vi U, vi V) {
n = B.size();
for (int i = 0; i < U.size(); i++){
int a = U[i], b = V[i];
adj[b].pb(a);
}
vi graph;
for (int i = 0; i < n; i++)
graph.pb(i), block[i] = 0, bel[i] = B[i];
while (!graph.empty()){
vi reach, rest;
for (auto u: graph)
if (spec[u])
reach.pb(u);
reach = func(1, reach);
rest = func(0, graph-reach);
if (rest.size() == 0)
break;
for (auto u: rest)
block[u] = 1;
graph = graph-rest;
}
vi res(n, 0);
for (auto u: graph)
res[u] = 1;
return res;
}
Compilation message
train.cpp: In function 'vi operator-(vi, vi)':
train.cpp:18:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | for (int i = 0, j = 0; i < a.size(); i++){
| ~~^~~~~~~~~~
train.cpp:19:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
19 | while (j < b.size() && b[j] < a[i])
| ~~^~~~~~~~~~
train.cpp:22:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | if (j == b.size() || b[j] > a[i])
| ~~^~~~~~~~~~~
train.cpp: In function 'vi who_wins(vi, vi, vi, vi)':
train.cpp:72:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
72 | for (int i = 0; i < U.size(); i++){
| ~~^~~~~~~~~~
train.cpp:100:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
100 | for (auto u: graph)
| ^~~
train.cpp:102:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
102 | return res;
| ^~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1024 KB |
Output is correct |
2 |
Correct |
7 ms |
1024 KB |
Output is correct |
3 |
Correct |
7 ms |
1024 KB |
Output is correct |
4 |
Correct |
7 ms |
1024 KB |
Output is correct |
5 |
Correct |
6 ms |
1024 KB |
Output is correct |
6 |
Correct |
6 ms |
1024 KB |
Output is correct |
7 |
Correct |
5 ms |
1024 KB |
Output is correct |
8 |
Correct |
7 ms |
1024 KB |
Output is correct |
9 |
Correct |
6 ms |
1024 KB |
Output is correct |
10 |
Correct |
6 ms |
896 KB |
Output is correct |
11 |
Correct |
5 ms |
896 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
512 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
512 KB |
Output is correct |
11 |
Correct |
0 ms |
512 KB |
Output is correct |
12 |
Correct |
1 ms |
512 KB |
Output is correct |
13 |
Correct |
1 ms |
448 KB |
Output is correct |
14 |
Correct |
0 ms |
512 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
512 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
0 ms |
512 KB |
Output is correct |
19 |
Correct |
0 ms |
384 KB |
Output is correct |
20 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
295 ms |
1280 KB |
Output is correct |
2 |
Correct |
508 ms |
1352 KB |
Output is correct |
3 |
Correct |
669 ms |
1344 KB |
Output is correct |
4 |
Correct |
9 ms |
1280 KB |
Output is correct |
5 |
Correct |
10 ms |
1280 KB |
Output is correct |
6 |
Correct |
10 ms |
1280 KB |
Output is correct |
7 |
Correct |
8 ms |
1280 KB |
Output is correct |
8 |
Correct |
9 ms |
1280 KB |
Output is correct |
9 |
Correct |
8 ms |
1248 KB |
Output is correct |
10 |
Correct |
9 ms |
1152 KB |
Output is correct |
11 |
Correct |
9 ms |
1152 KB |
Output is correct |
12 |
Correct |
8 ms |
1152 KB |
Output is correct |
13 |
Correct |
9 ms |
1280 KB |
Output is correct |
14 |
Correct |
9 ms |
1280 KB |
Output is correct |
15 |
Correct |
8 ms |
1280 KB |
Output is correct |
16 |
Correct |
9 ms |
1280 KB |
Output is correct |
17 |
Correct |
9 ms |
1280 KB |
Output is correct |
18 |
Correct |
838 ms |
1144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
1152 KB |
Output is correct |
2 |
Correct |
9 ms |
1152 KB |
Output is correct |
3 |
Correct |
9 ms |
1280 KB |
Output is correct |
4 |
Correct |
9 ms |
1280 KB |
Output is correct |
5 |
Correct |
10 ms |
1280 KB |
Output is correct |
6 |
Correct |
11 ms |
1152 KB |
Output is correct |
7 |
Correct |
12 ms |
1152 KB |
Output is correct |
8 |
Correct |
8 ms |
1276 KB |
Output is correct |
9 |
Correct |
9 ms |
1152 KB |
Output is correct |
10 |
Correct |
8 ms |
1280 KB |
Output is correct |
11 |
Correct |
9 ms |
1408 KB |
Output is correct |
12 |
Correct |
8 ms |
1280 KB |
Output is correct |
13 |
Correct |
10 ms |
1280 KB |
Output is correct |
14 |
Correct |
9 ms |
1152 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
1280 KB |
Output is correct |
2 |
Correct |
9 ms |
1280 KB |
Output is correct |
3 |
Correct |
10 ms |
1280 KB |
Output is correct |
4 |
Correct |
8 ms |
1152 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
7 ms |
896 KB |
Output is correct |
7 |
Correct |
6 ms |
896 KB |
Output is correct |
8 |
Correct |
6 ms |
896 KB |
Output is correct |
9 |
Correct |
6 ms |
896 KB |
Output is correct |
10 |
Correct |
2 ms |
640 KB |
Output is correct |
11 |
Correct |
5 ms |
896 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1024 KB |
Output is correct |
2 |
Correct |
7 ms |
1024 KB |
Output is correct |
3 |
Correct |
7 ms |
1024 KB |
Output is correct |
4 |
Correct |
7 ms |
1024 KB |
Output is correct |
5 |
Correct |
6 ms |
1024 KB |
Output is correct |
6 |
Correct |
6 ms |
1024 KB |
Output is correct |
7 |
Correct |
5 ms |
1024 KB |
Output is correct |
8 |
Correct |
7 ms |
1024 KB |
Output is correct |
9 |
Correct |
6 ms |
1024 KB |
Output is correct |
10 |
Correct |
6 ms |
896 KB |
Output is correct |
11 |
Correct |
5 ms |
896 KB |
Output is correct |
12 |
Correct |
1 ms |
512 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
512 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
0 ms |
384 KB |
Output is correct |
19 |
Correct |
0 ms |
384 KB |
Output is correct |
20 |
Correct |
0 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
512 KB |
Output is correct |
22 |
Correct |
0 ms |
512 KB |
Output is correct |
23 |
Correct |
1 ms |
512 KB |
Output is correct |
24 |
Correct |
1 ms |
448 KB |
Output is correct |
25 |
Correct |
0 ms |
512 KB |
Output is correct |
26 |
Correct |
0 ms |
384 KB |
Output is correct |
27 |
Correct |
0 ms |
512 KB |
Output is correct |
28 |
Correct |
1 ms |
384 KB |
Output is correct |
29 |
Correct |
0 ms |
512 KB |
Output is correct |
30 |
Correct |
0 ms |
384 KB |
Output is correct |
31 |
Correct |
0 ms |
384 KB |
Output is correct |
32 |
Correct |
295 ms |
1280 KB |
Output is correct |
33 |
Correct |
508 ms |
1352 KB |
Output is correct |
34 |
Correct |
669 ms |
1344 KB |
Output is correct |
35 |
Correct |
9 ms |
1280 KB |
Output is correct |
36 |
Correct |
10 ms |
1280 KB |
Output is correct |
37 |
Correct |
10 ms |
1280 KB |
Output is correct |
38 |
Correct |
8 ms |
1280 KB |
Output is correct |
39 |
Correct |
9 ms |
1280 KB |
Output is correct |
40 |
Correct |
8 ms |
1248 KB |
Output is correct |
41 |
Correct |
9 ms |
1152 KB |
Output is correct |
42 |
Correct |
9 ms |
1152 KB |
Output is correct |
43 |
Correct |
8 ms |
1152 KB |
Output is correct |
44 |
Correct |
9 ms |
1280 KB |
Output is correct |
45 |
Correct |
9 ms |
1280 KB |
Output is correct |
46 |
Correct |
8 ms |
1280 KB |
Output is correct |
47 |
Correct |
9 ms |
1280 KB |
Output is correct |
48 |
Correct |
9 ms |
1280 KB |
Output is correct |
49 |
Correct |
838 ms |
1144 KB |
Output is correct |
50 |
Correct |
8 ms |
1152 KB |
Output is correct |
51 |
Correct |
9 ms |
1152 KB |
Output is correct |
52 |
Correct |
9 ms |
1280 KB |
Output is correct |
53 |
Correct |
9 ms |
1280 KB |
Output is correct |
54 |
Correct |
10 ms |
1280 KB |
Output is correct |
55 |
Correct |
11 ms |
1152 KB |
Output is correct |
56 |
Correct |
12 ms |
1152 KB |
Output is correct |
57 |
Correct |
8 ms |
1276 KB |
Output is correct |
58 |
Correct |
9 ms |
1152 KB |
Output is correct |
59 |
Correct |
8 ms |
1280 KB |
Output is correct |
60 |
Correct |
9 ms |
1408 KB |
Output is correct |
61 |
Correct |
8 ms |
1280 KB |
Output is correct |
62 |
Correct |
10 ms |
1280 KB |
Output is correct |
63 |
Correct |
9 ms |
1152 KB |
Output is correct |
64 |
Correct |
10 ms |
1280 KB |
Output is correct |
65 |
Correct |
9 ms |
1280 KB |
Output is correct |
66 |
Correct |
10 ms |
1280 KB |
Output is correct |
67 |
Correct |
8 ms |
1152 KB |
Output is correct |
68 |
Correct |
1 ms |
512 KB |
Output is correct |
69 |
Correct |
7 ms |
896 KB |
Output is correct |
70 |
Correct |
6 ms |
896 KB |
Output is correct |
71 |
Correct |
6 ms |
896 KB |
Output is correct |
72 |
Correct |
6 ms |
896 KB |
Output is correct |
73 |
Correct |
2 ms |
640 KB |
Output is correct |
74 |
Correct |
5 ms |
896 KB |
Output is correct |
75 |
Correct |
431 ms |
1332 KB |
Output is correct |
76 |
Correct |
537 ms |
1312 KB |
Output is correct |
77 |
Correct |
701 ms |
1360 KB |
Output is correct |
78 |
Correct |
701 ms |
1552 KB |
Output is correct |
79 |
Correct |
693 ms |
1436 KB |
Output is correct |
80 |
Correct |
10 ms |
1280 KB |
Output is correct |
81 |
Correct |
10 ms |
1280 KB |
Output is correct |
82 |
Correct |
11 ms |
1280 KB |
Output is correct |
83 |
Correct |
11 ms |
1280 KB |
Output is correct |
84 |
Correct |
12 ms |
1280 KB |
Output is correct |
85 |
Correct |
10 ms |
1280 KB |
Output is correct |
86 |
Correct |
11 ms |
1280 KB |
Output is correct |
87 |
Correct |
10 ms |
1152 KB |
Output is correct |
88 |
Correct |
15 ms |
1280 KB |
Output is correct |
89 |
Correct |
10 ms |
1280 KB |
Output is correct |
90 |
Correct |
21 ms |
1280 KB |
Output is correct |
91 |
Correct |
19 ms |
1280 KB |
Output is correct |
92 |
Correct |
38 ms |
1280 KB |
Output is correct |
93 |
Correct |
41 ms |
1280 KB |
Output is correct |
94 |
Correct |
38 ms |
1280 KB |
Output is correct |
95 |
Correct |
41 ms |
1280 KB |
Output is correct |
96 |
Correct |
154 ms |
1268 KB |
Output is correct |
97 |
Correct |
605 ms |
1400 KB |
Output is correct |
98 |
Correct |
976 ms |
1280 KB |
Output is correct |
99 |
Correct |
1008 ms |
1376 KB |
Output is correct |
100 |
Correct |
820 ms |
1124 KB |
Output is correct |