#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std;
const int N =12;
vector<int> r , ans , u , v;
int n , m;
vector< int > g[N];
int cur = 0 , vis[N] , vi = 0 ;
void DFS(int node){
vis[node] = vi;
cur++;
for(int i=0;i<g[node].size();i++){
if(vis[g[node][i]] != vi) DFS(g[node][i]);
}
}
void calc(int i){
if(r.size() >= n) return;
if(i == m){
if(r.size() < n - 1) return;
for(int i=0;i<n;i++){
g[i].clear();
}
for(int i=0;i<r.size();i++){
g[u[r[i]]].push_back(v[r[i]]);
g[v[r[i]]].push_back(u[r[i]]);
}
cur = 0;
vi++;
DFS(0);
if(cur != n) return;
if(count_common_roads(r) == n-1){
ans = r;
}
return ;
}
r.push_back(i);
calc(i+1);
r.pop_back();
calc(i+1);
}
std::vector<int> find_roads(int N, std::vector<int> U, std::vector<int> V) {
u = U;
v = V;
n = N;
m = u.size();
r.clear();
calc(0);
return ans;
}
Compilation message
simurgh.cpp: In function 'void DFS(int)':
simurgh.cpp:12:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<g[node].size();i++){
^
simurgh.cpp: In function 'void calc(int)':
simurgh.cpp:18:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(r.size() >= n) return;
^
simurgh.cpp:20:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(r.size() < n - 1) return;
^
simurgh.cpp:24:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<r.size();i++){
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
2024 KB |
correct |
2 |
Correct |
9 ms |
2024 KB |
correct |
3 |
Correct |
13 ms |
2024 KB |
correct |
4 |
Correct |
0 ms |
2024 KB |
correct |
5 |
Correct |
0 ms |
2024 KB |
correct |
6 |
Correct |
0 ms |
2024 KB |
correct |
7 |
Correct |
0 ms |
2024 KB |
correct |
8 |
Correct |
0 ms |
2024 KB |
correct |
9 |
Correct |
0 ms |
2024 KB |
correct |
10 |
Correct |
0 ms |
2024 KB |
correct |
11 |
Correct |
0 ms |
2024 KB |
correct |
12 |
Correct |
0 ms |
2024 KB |
correct |
13 |
Correct |
9 ms |
2024 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
2024 KB |
correct |
2 |
Correct |
9 ms |
2024 KB |
correct |
3 |
Correct |
13 ms |
2024 KB |
correct |
4 |
Correct |
0 ms |
2024 KB |
correct |
5 |
Correct |
0 ms |
2024 KB |
correct |
6 |
Correct |
0 ms |
2024 KB |
correct |
7 |
Correct |
0 ms |
2024 KB |
correct |
8 |
Correct |
0 ms |
2024 KB |
correct |
9 |
Correct |
0 ms |
2024 KB |
correct |
10 |
Correct |
0 ms |
2024 KB |
correct |
11 |
Correct |
0 ms |
2024 KB |
correct |
12 |
Correct |
0 ms |
2024 KB |
correct |
13 |
Correct |
9 ms |
2024 KB |
correct |
14 |
Runtime error |
0 ms |
2024 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
2024 KB |
correct |
2 |
Correct |
9 ms |
2024 KB |
correct |
3 |
Correct |
13 ms |
2024 KB |
correct |
4 |
Correct |
0 ms |
2024 KB |
correct |
5 |
Correct |
0 ms |
2024 KB |
correct |
6 |
Correct |
0 ms |
2024 KB |
correct |
7 |
Correct |
0 ms |
2024 KB |
correct |
8 |
Correct |
0 ms |
2024 KB |
correct |
9 |
Correct |
0 ms |
2024 KB |
correct |
10 |
Correct |
0 ms |
2024 KB |
correct |
11 |
Correct |
0 ms |
2024 KB |
correct |
12 |
Correct |
0 ms |
2024 KB |
correct |
13 |
Correct |
9 ms |
2024 KB |
correct |
14 |
Runtime error |
0 ms |
2024 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2024 KB |
correct |
2 |
Incorrect |
76 ms |
2024 KB |
WA in grader: NO |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
2024 KB |
correct |
2 |
Correct |
9 ms |
2024 KB |
correct |
3 |
Correct |
13 ms |
2024 KB |
correct |
4 |
Correct |
0 ms |
2024 KB |
correct |
5 |
Correct |
0 ms |
2024 KB |
correct |
6 |
Correct |
0 ms |
2024 KB |
correct |
7 |
Correct |
0 ms |
2024 KB |
correct |
8 |
Correct |
0 ms |
2024 KB |
correct |
9 |
Correct |
0 ms |
2024 KB |
correct |
10 |
Correct |
0 ms |
2024 KB |
correct |
11 |
Correct |
0 ms |
2024 KB |
correct |
12 |
Correct |
0 ms |
2024 KB |
correct |
13 |
Correct |
9 ms |
2024 KB |
correct |
14 |
Runtime error |
0 ms |
2024 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
15 |
Halted |
0 ms |
0 KB |
- |