# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
617875 |
2022-08-01T16:01:55 Z |
sokratisi |
Keys (IOI21_keys) |
C++17 |
|
3000 ms |
17092 KB |
#include <vector>
#include <unordered_set>
using namespace std;
int solve(vector<int> r, vector<int> u, vector<int> v, vector<int> c, int s) {
unordered_set<int> vis;
unordered_set<int> keys;
vis.insert(s);
keys.insert(r[s]);
int added = 1;
int m = u.size();
while (added) {
added = 0;
for (int i = 0; i < m; i++) {
if (vis.find(u[i]) != vis.end()) {
if (vis.find(v[i]) == vis.end()) {
if (keys.find(c[i]) != keys.end()) {
added++;
vis.insert(v[i]);
keys.insert(r[v[i]]);
}
}
}
}
for (int i = 0; i < m; i++) {
if (vis.find(v[i]) != vis.end()) {
if (vis.find(u[i]) == vis.end()) {
if (keys.find(c[i]) != keys.end()) {
added++;
vis.insert(u[i]);
keys.insert(r[u[i]]);
}
}
}
}
}
return vis.size();
}
vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) {
int n = r.size();
vector<int> canreach(n);
for (int i = 0; i < n; i++) {
canreach[i] = solve(r, u, v, c, i);
// printf("%d\n", canreach[i]);
}
int least = canreach[0];
for (int i = 1; i < n; i++) least = min(least, canreach[i]);
vector<int> ans(n, 0);
for (int i = 0; i < n; i++) if (canreach[i] == least) ans[i] = 1;
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
292 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
288 KB |
Output is correct |
4 |
Correct |
5 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
7 ms |
212 KB |
Output is correct |
9 |
Correct |
8 ms |
284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
292 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
288 KB |
Output is correct |
4 |
Correct |
5 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
7 ms |
212 KB |
Output is correct |
9 |
Correct |
8 ms |
284 KB |
Output is correct |
10 |
Correct |
35 ms |
292 KB |
Output is correct |
11 |
Correct |
33 ms |
304 KB |
Output is correct |
12 |
Correct |
37 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
18 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
6 ms |
280 KB |
Output is correct |
22 |
Correct |
7 ms |
300 KB |
Output is correct |
23 |
Correct |
43 ms |
212 KB |
Output is correct |
24 |
Correct |
73 ms |
300 KB |
Output is correct |
25 |
Correct |
79 ms |
292 KB |
Output is correct |
26 |
Correct |
114 ms |
292 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
292 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
288 KB |
Output is correct |
4 |
Correct |
5 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
7 ms |
212 KB |
Output is correct |
9 |
Correct |
8 ms |
284 KB |
Output is correct |
10 |
Correct |
35 ms |
292 KB |
Output is correct |
11 |
Correct |
33 ms |
304 KB |
Output is correct |
12 |
Correct |
37 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
18 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
6 ms |
280 KB |
Output is correct |
22 |
Correct |
7 ms |
300 KB |
Output is correct |
23 |
Correct |
43 ms |
212 KB |
Output is correct |
24 |
Correct |
73 ms |
300 KB |
Output is correct |
25 |
Correct |
79 ms |
292 KB |
Output is correct |
26 |
Correct |
114 ms |
292 KB |
Output is correct |
27 |
Execution timed out |
3066 ms |
604 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
292 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
288 KB |
Output is correct |
4 |
Correct |
5 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
7 ms |
212 KB |
Output is correct |
9 |
Correct |
8 ms |
284 KB |
Output is correct |
10 |
Execution timed out |
3060 ms |
17092 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
292 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
288 KB |
Output is correct |
4 |
Correct |
5 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
7 ms |
212 KB |
Output is correct |
9 |
Correct |
8 ms |
284 KB |
Output is correct |
10 |
Correct |
35 ms |
292 KB |
Output is correct |
11 |
Correct |
33 ms |
304 KB |
Output is correct |
12 |
Correct |
37 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
18 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
6 ms |
280 KB |
Output is correct |
22 |
Correct |
7 ms |
300 KB |
Output is correct |
23 |
Correct |
43 ms |
212 KB |
Output is correct |
24 |
Correct |
73 ms |
300 KB |
Output is correct |
25 |
Correct |
79 ms |
292 KB |
Output is correct |
26 |
Correct |
114 ms |
292 KB |
Output is correct |
27 |
Execution timed out |
3066 ms |
604 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |