#include "simurgh.h"
#include<bits/stdc++.h>
using namespace std;
const int N = 55;
const int _ = 1;
int g[N][N], gud[N * N];
vector <int> cur;
int n;
int used[N];
void init(int v) {
used[v] = 1;
for (int i = 0; i < n; i++) {
if (used[i] == 0 && g[v][i] > -1) {
cur.push_back(g[v][i]);
init(i);
}
}
}
void dfs(int v) {
used[v] = 1;
for (int i = 0; i < n; i++) {
if (used[i] == 0 && g[v][i] > -1 && gud[g[v][i]] == 1) {
dfs(i);
}
}
}
int check() {
memset(used, 0, sizeof(used));
memset(gud, 0, sizeof(gud));
for (int i : cur) gud[i] = 1;
dfs(0);
for (int i = 0; i < n; i++) {
if (used[i] == 0) return 0;
}
return 1;
}
vector <int> find_roads(int n, vector <int> u, vector <int> v) {
::n = n;
int m = u.size();
memset(g, -1, sizeof(g));
for (int i = 0; i < m; i++) {
g[u[i]][v[i]] = g[v[i]][u[i]] = i;
}
init(0);
while(3^_^3) {
int now = count_common_roads(cur);
if (now == n - 1) return cur;
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < m; j++) {
if (cur[i] != j) {
int old = cur[i];
cur[i] = j;
if (check() == 1) {
int noww = count_common_roads(cur);
if (noww > now) {
now = noww;
} else cur[i] = old;
} else cur[i] = old;
}
}
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
correct |
2 |
Correct |
2 ms |
376 KB |
correct |
3 |
Correct |
2 ms |
376 KB |
correct |
4 |
Correct |
2 ms |
380 KB |
correct |
5 |
Correct |
2 ms |
376 KB |
correct |
6 |
Correct |
2 ms |
376 KB |
correct |
7 |
Correct |
2 ms |
376 KB |
correct |
8 |
Correct |
4 ms |
376 KB |
correct |
9 |
Correct |
2 ms |
376 KB |
correct |
10 |
Correct |
2 ms |
380 KB |
correct |
11 |
Correct |
2 ms |
380 KB |
correct |
12 |
Correct |
2 ms |
376 KB |
correct |
13 |
Correct |
2 ms |
376 KB |
correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
correct |
2 |
Correct |
2 ms |
376 KB |
correct |
3 |
Correct |
2 ms |
376 KB |
correct |
4 |
Correct |
2 ms |
380 KB |
correct |
5 |
Correct |
2 ms |
376 KB |
correct |
6 |
Correct |
2 ms |
376 KB |
correct |
7 |
Correct |
2 ms |
376 KB |
correct |
8 |
Correct |
4 ms |
376 KB |
correct |
9 |
Correct |
2 ms |
376 KB |
correct |
10 |
Correct |
2 ms |
380 KB |
correct |
11 |
Correct |
2 ms |
380 KB |
correct |
12 |
Correct |
2 ms |
376 KB |
correct |
13 |
Correct |
2 ms |
376 KB |
correct |
14 |
Correct |
344 ms |
476 KB |
correct |
15 |
Correct |
269 ms |
408 KB |
correct |
16 |
Correct |
291 ms |
508 KB |
correct |
17 |
Correct |
373 ms |
376 KB |
correct |
18 |
Correct |
170 ms |
376 KB |
correct |
19 |
Correct |
330 ms |
504 KB |
correct |
20 |
Correct |
345 ms |
504 KB |
correct |
21 |
Correct |
380 ms |
376 KB |
correct |
22 |
Correct |
264 ms |
376 KB |
correct |
23 |
Correct |
231 ms |
376 KB |
correct |
24 |
Correct |
213 ms |
476 KB |
correct |
25 |
Correct |
38 ms |
376 KB |
correct |
26 |
Correct |
210 ms |
504 KB |
correct |
27 |
Correct |
253 ms |
376 KB |
correct |
28 |
Correct |
94 ms |
376 KB |
correct |
29 |
Correct |
47 ms |
388 KB |
correct |
30 |
Correct |
265 ms |
428 KB |
correct |
31 |
Correct |
244 ms |
376 KB |
correct |
32 |
Correct |
278 ms |
504 KB |
correct |
33 |
Correct |
246 ms |
380 KB |
correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
correct |
2 |
Correct |
2 ms |
376 KB |
correct |
3 |
Correct |
2 ms |
376 KB |
correct |
4 |
Correct |
2 ms |
380 KB |
correct |
5 |
Correct |
2 ms |
376 KB |
correct |
6 |
Correct |
2 ms |
376 KB |
correct |
7 |
Correct |
2 ms |
376 KB |
correct |
8 |
Correct |
4 ms |
376 KB |
correct |
9 |
Correct |
2 ms |
376 KB |
correct |
10 |
Correct |
2 ms |
380 KB |
correct |
11 |
Correct |
2 ms |
380 KB |
correct |
12 |
Correct |
2 ms |
376 KB |
correct |
13 |
Correct |
2 ms |
376 KB |
correct |
14 |
Correct |
344 ms |
476 KB |
correct |
15 |
Correct |
269 ms |
408 KB |
correct |
16 |
Correct |
291 ms |
508 KB |
correct |
17 |
Correct |
373 ms |
376 KB |
correct |
18 |
Correct |
170 ms |
376 KB |
correct |
19 |
Correct |
330 ms |
504 KB |
correct |
20 |
Correct |
345 ms |
504 KB |
correct |
21 |
Correct |
380 ms |
376 KB |
correct |
22 |
Correct |
264 ms |
376 KB |
correct |
23 |
Correct |
231 ms |
376 KB |
correct |
24 |
Correct |
213 ms |
476 KB |
correct |
25 |
Correct |
38 ms |
376 KB |
correct |
26 |
Correct |
210 ms |
504 KB |
correct |
27 |
Correct |
253 ms |
376 KB |
correct |
28 |
Correct |
94 ms |
376 KB |
correct |
29 |
Correct |
47 ms |
388 KB |
correct |
30 |
Correct |
265 ms |
428 KB |
correct |
31 |
Correct |
244 ms |
376 KB |
correct |
32 |
Correct |
278 ms |
504 KB |
correct |
33 |
Correct |
246 ms |
380 KB |
correct |
34 |
Runtime error |
10 ms |
1656 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
35 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
correct |
2 |
Correct |
2 ms |
376 KB |
correct |
3 |
Runtime error |
22 ms |
3704 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
correct |
2 |
Correct |
2 ms |
376 KB |
correct |
3 |
Correct |
2 ms |
376 KB |
correct |
4 |
Correct |
2 ms |
380 KB |
correct |
5 |
Correct |
2 ms |
376 KB |
correct |
6 |
Correct |
2 ms |
376 KB |
correct |
7 |
Correct |
2 ms |
376 KB |
correct |
8 |
Correct |
4 ms |
376 KB |
correct |
9 |
Correct |
2 ms |
376 KB |
correct |
10 |
Correct |
2 ms |
380 KB |
correct |
11 |
Correct |
2 ms |
380 KB |
correct |
12 |
Correct |
2 ms |
376 KB |
correct |
13 |
Correct |
2 ms |
376 KB |
correct |
14 |
Correct |
344 ms |
476 KB |
correct |
15 |
Correct |
269 ms |
408 KB |
correct |
16 |
Correct |
291 ms |
508 KB |
correct |
17 |
Correct |
373 ms |
376 KB |
correct |
18 |
Correct |
170 ms |
376 KB |
correct |
19 |
Correct |
330 ms |
504 KB |
correct |
20 |
Correct |
345 ms |
504 KB |
correct |
21 |
Correct |
380 ms |
376 KB |
correct |
22 |
Correct |
264 ms |
376 KB |
correct |
23 |
Correct |
231 ms |
376 KB |
correct |
24 |
Correct |
213 ms |
476 KB |
correct |
25 |
Correct |
38 ms |
376 KB |
correct |
26 |
Correct |
210 ms |
504 KB |
correct |
27 |
Correct |
253 ms |
376 KB |
correct |
28 |
Correct |
94 ms |
376 KB |
correct |
29 |
Correct |
47 ms |
388 KB |
correct |
30 |
Correct |
265 ms |
428 KB |
correct |
31 |
Correct |
244 ms |
376 KB |
correct |
32 |
Correct |
278 ms |
504 KB |
correct |
33 |
Correct |
246 ms |
380 KB |
correct |
34 |
Runtime error |
10 ms |
1656 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
35 |
Halted |
0 ms |
0 KB |
- |