Submission #428155

# Submission time Handle Problem Language Result Execution time Memory
428155 2021-06-15T08:30:15 Z jeqcho Simurgh (IOI17_simurgh) C++17
0 / 100
1355 ms 1048580 KB
#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define F0R(i,b) FOR(i,0,b)
#define ROF(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define R0F(i,b) ROF(i,0,b)
#define all(x) begin(x),end(x)
#define pb push_back
#define trav(a,x) for(auto&a:x)
#define sz(x) int(x.size())

vi u;
vi v;
int n,m;
bool done=0;
vi ans;
int const N=7+3;
vi adj[N];
bool vis[N];

void dfs(int now,int par)
{
	vis[now]=1;
	trav(chi,adj[now])
	{
		if(chi==par)continue;
		dfs(chi,now);
	}
}
vi cur;

bool valid()
{
	F0R(i,n)adj[i].clear();
	fill(vis,vis+n,0);
	F0R(i,n-1)
	{
		adj[u[i]].pb(v[i]);
		adj[v[i]].pb(u[i]);
	}
	dfs(0,-1);
	F0R(i,n)
	{
		if(!vis[i])return 0;
	}
	return 1;
}

void recur(int now)
{
	if(done)return;
	if(now==m)
	{
		if(sz(cur)!=n-1)return;
		if(!valid())return;
		int res = count_common_roads(cur);
		if(res==n-1)
		{
			ans=cur;
			done=1;
		}
		return;
	}
	recur(now+1);
	cur.pb(now);
	recur(now+1);
	cur.pop_back();
}

vi find_roads(int n1, vi u1, vi v1) {
	n=n1;
	m=sz(u1);
	u=u1;
	v=v1;
	recur(0);
	assert(done);
	return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1355 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1355 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1355 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB correct
2 Runtime error 1175 ms 1048580 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1355 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -