#include <bits/stdc++.h>
#include "simurgh.h"
using namespace std;
const int maxn = 7;
vector<int> find_roads(int n, vector<int> u, vector<int> v) {
vector <int> r (n - 1, 0);
int m = u.size();
auto check = [&] (vector <int> idx) {
vector <vector <int> > ad(maxn);
for (int i: idx) {
ad[u[i]].push_back(v[i]);
ad[v[i]].push_back(u[i]);
}
bitset <maxn> vis = 0;
auto dfs = [&] (int u, auto&& dfs) -> void {
vis[u] = 1;
for (int v: ad[u]) {
if (!vis[v]) dfs(v, dfs);
}
return;
};
dfs(0, dfs);
for (int i = 0; i < n; i++){
if (!vis[i]) return;
}
if (count_common_roads(idx) == n - 1) r = idx;
};
auto back = [&] (int step, int pos, vector <int> &used, auto&& back) -> void {
if (step == n - 1) {
vector <int> idx;
for (int i = 0; i < m; i++){
if (used[i]) idx.push_back(i);
}
check(idx);
return;
}
for (int i = pos + 1; i < m; i++){
if (!used[i]) {
used[i] = 1;
back(step + 1, i, used, back);
used[i] = 0;
}
}
return;
};
back(0, -1, *(new vector <int> (m, 0)), back);
return r;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
288 KB |
correct |
2 |
Correct |
44 ms |
212 KB |
correct |
3 |
Correct |
42 ms |
280 KB |
correct |
4 |
Correct |
2 ms |
212 KB |
correct |
5 |
Correct |
1 ms |
212 KB |
correct |
6 |
Correct |
6 ms |
212 KB |
correct |
7 |
Correct |
0 ms |
212 KB |
correct |
8 |
Correct |
0 ms |
300 KB |
correct |
9 |
Correct |
0 ms |
212 KB |
correct |
10 |
Correct |
2 ms |
212 KB |
correct |
11 |
Correct |
1 ms |
212 KB |
correct |
12 |
Correct |
2 ms |
212 KB |
correct |
13 |
Correct |
42 ms |
280 KB |
correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
288 KB |
correct |
2 |
Correct |
44 ms |
212 KB |
correct |
3 |
Correct |
42 ms |
280 KB |
correct |
4 |
Correct |
2 ms |
212 KB |
correct |
5 |
Correct |
1 ms |
212 KB |
correct |
6 |
Correct |
6 ms |
212 KB |
correct |
7 |
Correct |
0 ms |
212 KB |
correct |
8 |
Correct |
0 ms |
300 KB |
correct |
9 |
Correct |
0 ms |
212 KB |
correct |
10 |
Correct |
2 ms |
212 KB |
correct |
11 |
Correct |
1 ms |
212 KB |
correct |
12 |
Correct |
2 ms |
212 KB |
correct |
13 |
Correct |
42 ms |
280 KB |
correct |
14 |
Runtime error |
3 ms |
568 KB |
Execution killed with signal 6 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
288 KB |
correct |
2 |
Correct |
44 ms |
212 KB |
correct |
3 |
Correct |
42 ms |
280 KB |
correct |
4 |
Correct |
2 ms |
212 KB |
correct |
5 |
Correct |
1 ms |
212 KB |
correct |
6 |
Correct |
6 ms |
212 KB |
correct |
7 |
Correct |
0 ms |
212 KB |
correct |
8 |
Correct |
0 ms |
300 KB |
correct |
9 |
Correct |
0 ms |
212 KB |
correct |
10 |
Correct |
2 ms |
212 KB |
correct |
11 |
Correct |
1 ms |
212 KB |
correct |
12 |
Correct |
2 ms |
212 KB |
correct |
13 |
Correct |
42 ms |
280 KB |
correct |
14 |
Runtime error |
3 ms |
568 KB |
Execution killed with signal 6 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
correct |
2 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
288 KB |
correct |
2 |
Correct |
44 ms |
212 KB |
correct |
3 |
Correct |
42 ms |
280 KB |
correct |
4 |
Correct |
2 ms |
212 KB |
correct |
5 |
Correct |
1 ms |
212 KB |
correct |
6 |
Correct |
6 ms |
212 KB |
correct |
7 |
Correct |
0 ms |
212 KB |
correct |
8 |
Correct |
0 ms |
300 KB |
correct |
9 |
Correct |
0 ms |
212 KB |
correct |
10 |
Correct |
2 ms |
212 KB |
correct |
11 |
Correct |
1 ms |
212 KB |
correct |
12 |
Correct |
2 ms |
212 KB |
correct |
13 |
Correct |
42 ms |
280 KB |
correct |
14 |
Runtime error |
3 ms |
568 KB |
Execution killed with signal 6 |
15 |
Halted |
0 ms |
0 KB |
- |