Submission #428180

# Submission time Handle Problem Language Result Execution time Memory
428180 2021-06-15T08:41:26 Z jeqcho Simurgh (IOI17_simurgh) C++17
13 / 100
3000 ms 332 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)
{
	if(vis[now])return;
	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[cur[i]]].pb(v[cur[i]]);
		adj[v[cur[i]]].pb(u[cur[i]]);
	}
	dfs(0,-1);
	F0R(i,n)
	{
		if(!vis[i])return 0;
	}
	return 1;
}

void recur(int now)
{
	if(sz(cur)>=n)return;
	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 Correct 1 ms 204 KB correct
2 Correct 16 ms 292 KB correct
3 Correct 6 ms 288 KB correct
4 Correct 1 ms 204 KB correct
5 Correct 1 ms 288 KB correct
6 Correct 2 ms 204 KB correct
7 Correct 1 ms 204 KB correct
8 Correct 1 ms 204 KB correct
9 Correct 1 ms 204 KB correct
10 Correct 1 ms 204 KB correct
11 Correct 1 ms 204 KB correct
12 Correct 1 ms 204 KB correct
13 Correct 6 ms 204 KB correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB correct
2 Correct 16 ms 292 KB correct
3 Correct 6 ms 288 KB correct
4 Correct 1 ms 204 KB correct
5 Correct 1 ms 288 KB correct
6 Correct 2 ms 204 KB correct
7 Correct 1 ms 204 KB correct
8 Correct 1 ms 204 KB correct
9 Correct 1 ms 204 KB correct
10 Correct 1 ms 204 KB correct
11 Correct 1 ms 204 KB correct
12 Correct 1 ms 204 KB correct
13 Correct 6 ms 204 KB correct
14 Execution timed out 3071 ms 332 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB correct
2 Correct 16 ms 292 KB correct
3 Correct 6 ms 288 KB correct
4 Correct 1 ms 204 KB correct
5 Correct 1 ms 288 KB correct
6 Correct 2 ms 204 KB correct
7 Correct 1 ms 204 KB correct
8 Correct 1 ms 204 KB correct
9 Correct 1 ms 204 KB correct
10 Correct 1 ms 204 KB correct
11 Correct 1 ms 204 KB correct
12 Correct 1 ms 204 KB correct
13 Correct 6 ms 204 KB correct
14 Execution timed out 3071 ms 332 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB correct
2 Incorrect 41 ms 204 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB correct
2 Correct 16 ms 292 KB correct
3 Correct 6 ms 288 KB correct
4 Correct 1 ms 204 KB correct
5 Correct 1 ms 288 KB correct
6 Correct 2 ms 204 KB correct
7 Correct 1 ms 204 KB correct
8 Correct 1 ms 204 KB correct
9 Correct 1 ms 204 KB correct
10 Correct 1 ms 204 KB correct
11 Correct 1 ms 204 KB correct
12 Correct 1 ms 204 KB correct
13 Correct 6 ms 204 KB correct
14 Execution timed out 3071 ms 332 KB Time limit exceeded
15 Halted 0 ms 0 KB -