Submission #428151

# Submission time Handle Problem Language Result Execution time Memory
428151 2021-06-15T08:27:34 Z jeqcho Simurgh (IOI17_simurgh) C++17
0 / 100
1199 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=500+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);
	}
}

bool valid(vi cur)
{
	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,vi cur)
{
	if(done)return;
	if(now==m)
	{
		if(sz(cur)!=n-1)return;
		if(!valid(cur))return;
		int res = count_common_roads(cur);
		if(res==n-1)
		{
			ans=cur;
			done=1;
		}
		return;
	}
	recur(now+1,cur);
	cur.pb(now);
	recur(now+1,cur);
}

vi find_roads(int n1, vi u1, vi v1) {
	n=n1;
	m=sz(u1);
	u=u1;
	v=v1;
	recur(0,vi {});
	assert(done);
	return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1199 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1199 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1199 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 1149 ms 1048580 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1199 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -