답안 #359016

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
359016 2021-01-26T09:05:30 Z amunduzbaev Simurgh (IOI17_simurgh) C++14
0 / 100
1319 ms 1048580 KB
#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, int p = -1){
	used[u] = 1;
	for(auto x:edges[u]){
		if(!ue[x.ss] || used[x.ff]) continue;
		dfs(x.ff, u);
	}
}

bool check(vii tt){
	for(int i=0;i<max(nn, mm);i++) ue[i] = 0, used[i] = 0;
	for(auto x:tt) ue[x] = 1;
	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);i++) 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 Runtime error 1293 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1293 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1293 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1319 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1293 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -