#include "simurgh.h"
#ifndef EVAL
#include "grader.cpp"
#endif
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define NeedForSpeed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vii;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
template<class T> bool umin(T& a, const T& b) {return a > b? a = b, true:false;}
template<class T> bool umax(T& a, const T& b) {return a < b? a = b, true:false;}
int msb(int val){return sizeof(int)*8-__builtin_clzll(val)-1;}
const int N = 105;
const int mod = 1e9+7;
const ll inf = 1e18;
const ld Pi = acos(-1);
int used[N], ue[N], ans, nn, mm;
vpii edges[N];
vii qq;
void dfs(int u){
used[u] = 1;
for(auto x:edges[u]){
if(ue[x.ss] || used[x.ff]) continue;
dfs(x.ff);
}
}
bool check(vii tt){
for(int i=0;i<max(nn, mm);i++) ue[i] = 1, used[i] = 0;
for(auto x:tt) ue[x] = 0;
dfs(0);
for(int i=0;i<nn;i++){
if(!used[i]) return 0;
}return 1;
}
vector<int> find_roads(int n, vector<int> u, vector<int> v) {
nn = n, mm = sz(u);
for(int i=0;i<sz(u);i++){
edges[u[i]].pb({v[i], i});
edges[v[i]].pb({u[i], i});
}
vii res;
for(int i=0;i<(1<<(nn*(nn-1)/2 +1));i++){
if(__builtin_popcount(i) != n-1) continue;
vii tt;
for(int j=0;j<(nn*(nn-1)/2);j++) if(i & (1<<j)) tt.pb(j);
if(check(tt)){
//for(auto x:tt) cout<<x<<" ";
//cout<<"\n";
//cout<<endl;
int tmp = count_common_roads(tt);
if(tmp == n-1) { res = tt; break; }
}
}return res;
}
/*
5 7
0 1
0 2
1 2
2 3
2 4
3 4
1 4
0
2
4
5
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
364 KB |
correct |
2 |
Correct |
29 ms |
364 KB |
correct |
3 |
Correct |
34 ms |
376 KB |
correct |
4 |
Correct |
2 ms |
360 KB |
correct |
5 |
Correct |
1 ms |
364 KB |
correct |
6 |
Correct |
4 ms |
364 KB |
correct |
7 |
Correct |
1 ms |
364 KB |
correct |
8 |
Correct |
1 ms |
364 KB |
correct |
9 |
Correct |
1 ms |
376 KB |
correct |
10 |
Correct |
1 ms |
364 KB |
correct |
11 |
Correct |
1 ms |
364 KB |
correct |
12 |
Correct |
1 ms |
364 KB |
correct |
13 |
Correct |
15 ms |
364 KB |
correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
364 KB |
correct |
2 |
Correct |
29 ms |
364 KB |
correct |
3 |
Correct |
34 ms |
376 KB |
correct |
4 |
Correct |
2 ms |
360 KB |
correct |
5 |
Correct |
1 ms |
364 KB |
correct |
6 |
Correct |
4 ms |
364 KB |
correct |
7 |
Correct |
1 ms |
364 KB |
correct |
8 |
Correct |
1 ms |
364 KB |
correct |
9 |
Correct |
1 ms |
376 KB |
correct |
10 |
Correct |
1 ms |
364 KB |
correct |
11 |
Correct |
1 ms |
364 KB |
correct |
12 |
Correct |
1 ms |
364 KB |
correct |
13 |
Correct |
15 ms |
364 KB |
correct |
14 |
Incorrect |
1 ms |
364 KB |
WA in grader: NO |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
364 KB |
correct |
2 |
Correct |
29 ms |
364 KB |
correct |
3 |
Correct |
34 ms |
376 KB |
correct |
4 |
Correct |
2 ms |
360 KB |
correct |
5 |
Correct |
1 ms |
364 KB |
correct |
6 |
Correct |
4 ms |
364 KB |
correct |
7 |
Correct |
1 ms |
364 KB |
correct |
8 |
Correct |
1 ms |
364 KB |
correct |
9 |
Correct |
1 ms |
376 KB |
correct |
10 |
Correct |
1 ms |
364 KB |
correct |
11 |
Correct |
1 ms |
364 KB |
correct |
12 |
Correct |
1 ms |
364 KB |
correct |
13 |
Correct |
15 ms |
364 KB |
correct |
14 |
Incorrect |
1 ms |
364 KB |
WA in grader: NO |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
correct |
2 |
Incorrect |
1 ms |
364 KB |
WA in grader: NO |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
364 KB |
correct |
2 |
Correct |
29 ms |
364 KB |
correct |
3 |
Correct |
34 ms |
376 KB |
correct |
4 |
Correct |
2 ms |
360 KB |
correct |
5 |
Correct |
1 ms |
364 KB |
correct |
6 |
Correct |
4 ms |
364 KB |
correct |
7 |
Correct |
1 ms |
364 KB |
correct |
8 |
Correct |
1 ms |
364 KB |
correct |
9 |
Correct |
1 ms |
376 KB |
correct |
10 |
Correct |
1 ms |
364 KB |
correct |
11 |
Correct |
1 ms |
364 KB |
correct |
12 |
Correct |
1 ms |
364 KB |
correct |
13 |
Correct |
15 ms |
364 KB |
correct |
14 |
Incorrect |
1 ms |
364 KB |
WA in grader: NO |
15 |
Halted |
0 ms |
0 KB |
- |