#include <vector>
#include <bits/stdc++.h>
using namespace std;
vector<int> vis;
vector<vector<vector<int>>> edg;
vector<int> reach;
set<int> keys;
int curr;
vector<int> k;
void dfs(int num) {
for (auto e : keys) {
vector<int> con;
con = edg[e][num];
for (auto v : con) {
if (vis[v] != 1) {
vis[v] = 1;
keys.insert(k[v]);
curr++;
dfs(v);
}
}
}
}
std::vector<int> find_reachable(std::vector<int> r, std::vector<int> u, std::vector<int> v, std::vector<int> c) {
k = r;
int rooms = r.size();
vis.resize(rooms);
edg.resize(rooms);
reach.resize(rooms);
for (int i = 0; i < rooms; i++) {
edg[i].resize(rooms);
}
int e = u.size();
for (int i = 0; i < e; i++) {
edg[c[i]][u[i]].push_back(v[i]);
edg[c[i]][v[i]].push_back(u[i]);
}
for (int i = 0; i < rooms; i++) {
keys.insert(r[i]);
curr = 1;
vis[i] = 1;
dfs(i);
// cout << "hello" << endl;
reach[i] = curr;
vis.clear();
vis.resize(rooms);
keys.clear();
}
int mn = reach[0];
for (int i = 1; i < rooms; i ++) {
if (reach[i] < mn) {
mn = reach[i];
}
}
vector<int> res;
res.resize(rooms);
for (int i = 0; i < rooms; i++) {
if (reach[i] != mn) {
res[i] = 0;
} else {
res[i] = 1;
}
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
1084 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
2 ms |
844 KB |
Output is correct |
9 |
Correct |
4 ms |
972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
1084 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
2 ms |
844 KB |
Output is correct |
9 |
Correct |
4 ms |
972 KB |
Output is correct |
10 |
Correct |
2 ms |
1228 KB |
Output is correct |
11 |
Correct |
1 ms |
1228 KB |
Output is correct |
12 |
Correct |
1 ms |
1228 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
11 ms |
780 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
460 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
47 ms |
1228 KB |
Output is correct |
22 |
Correct |
6 ms |
332 KB |
Output is correct |
23 |
Correct |
44 ms |
844 KB |
Output is correct |
24 |
Correct |
45 ms |
844 KB |
Output is correct |
25 |
Correct |
94 ms |
1168 KB |
Output is correct |
26 |
Correct |
104 ms |
1176 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
1084 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
2 ms |
844 KB |
Output is correct |
9 |
Correct |
4 ms |
972 KB |
Output is correct |
10 |
Correct |
2 ms |
1228 KB |
Output is correct |
11 |
Correct |
1 ms |
1228 KB |
Output is correct |
12 |
Correct |
1 ms |
1228 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
11 ms |
780 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
460 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
47 ms |
1228 KB |
Output is correct |
22 |
Correct |
6 ms |
332 KB |
Output is correct |
23 |
Correct |
44 ms |
844 KB |
Output is correct |
24 |
Correct |
45 ms |
844 KB |
Output is correct |
25 |
Correct |
94 ms |
1168 KB |
Output is correct |
26 |
Correct |
104 ms |
1176 KB |
Output is correct |
27 |
Correct |
64 ms |
94288 KB |
Output is correct |
28 |
Correct |
68 ms |
94400 KB |
Output is correct |
29 |
Correct |
65 ms |
94468 KB |
Output is correct |
30 |
Execution timed out |
2536 ms |
17304 KB |
Time limit exceeded |
31 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
1084 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
2 ms |
844 KB |
Output is correct |
9 |
Correct |
4 ms |
972 KB |
Output is correct |
10 |
Runtime error |
1384 ms |
1048580 KB |
Execution killed with signal 9 |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
1084 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
2 ms |
844 KB |
Output is correct |
9 |
Correct |
4 ms |
972 KB |
Output is correct |
10 |
Correct |
2 ms |
1228 KB |
Output is correct |
11 |
Correct |
1 ms |
1228 KB |
Output is correct |
12 |
Correct |
1 ms |
1228 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
11 ms |
780 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
460 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
47 ms |
1228 KB |
Output is correct |
22 |
Correct |
6 ms |
332 KB |
Output is correct |
23 |
Correct |
44 ms |
844 KB |
Output is correct |
24 |
Correct |
45 ms |
844 KB |
Output is correct |
25 |
Correct |
94 ms |
1168 KB |
Output is correct |
26 |
Correct |
104 ms |
1176 KB |
Output is correct |
27 |
Correct |
64 ms |
94288 KB |
Output is correct |
28 |
Correct |
68 ms |
94400 KB |
Output is correct |
29 |
Correct |
65 ms |
94468 KB |
Output is correct |
30 |
Execution timed out |
2536 ms |
17304 KB |
Time limit exceeded |
31 |
Halted |
0 ms |
0 KB |
- |