Submission #429924

# Submission time Handle Problem Language Result Execution time Memory
429924 2021-06-16T10:33:20 Z AmineWeslati Simurgh (IOI17_simurgh) C++14
13 / 100
697 ms 460 KB
#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std; 

typedef long long ll;
typedef vector<int>vi; 
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x),end(x)

#define FOR(i,a,b) for(int i=a; i<b; i++)

//--------------------------------

const int MX=100;
int N; 
vi adj[MX];

vi vis(MX);
void dfs(int u){
	vis[u]=1;
	for(int v: adj[u]) if(!vis[v]) dfs(v);
}
bool check(){
	FOR(i,0,N) vis[i]=0;
	dfs(0);
	FOR(i,0,N) if(!vis[i]) return 0;
	return 1;
}

vi find_roads(int N, vi U, vi V) {
	int M=sz(U);
	::N=N; 
	FOR(m,1,1<<M){
		FOR(i,0,N) adj[i].clear();

		vi vec;
		FOR(i,0,M) if((m>>i)&1){
			int u=U[i],v=V[i];
			adj[u].pb(v);
			adj[v].pb(u);
			vec.pb(i);
		}
		if(sz(vec)==N-1 && check() && count_common_roads(vec)==N-1){
			return vec; 
		}
	}
	assert(0);
}

/*

4 6
0 1
0 2
0 3
1 2
1 3
2 3
0 1 5

*/
# Verdict Execution time Memory Grader output
1 Correct 54 ms 268 KB correct
2 Correct 596 ms 272 KB correct
3 Correct 697 ms 324 KB correct
4 Correct 2 ms 204 KB correct
5 Correct 1 ms 204 KB correct
6 Correct 14 ms 292 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 4 ms 204 KB correct
11 Correct 1 ms 204 KB correct
12 Correct 6 ms 204 KB correct
13 Correct 182 ms 204 KB correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 268 KB correct
2 Correct 596 ms 272 KB correct
3 Correct 697 ms 324 KB correct
4 Correct 2 ms 204 KB correct
5 Correct 1 ms 204 KB correct
6 Correct 14 ms 292 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 4 ms 204 KB correct
11 Correct 1 ms 204 KB correct
12 Correct 6 ms 204 KB correct
13 Correct 182 ms 204 KB correct
14 Runtime error 5 ms 460 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 54 ms 268 KB correct
2 Correct 596 ms 272 KB correct
3 Correct 697 ms 324 KB correct
4 Correct 2 ms 204 KB correct
5 Correct 1 ms 204 KB correct
6 Correct 14 ms 292 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 4 ms 204 KB correct
11 Correct 1 ms 204 KB correct
12 Correct 6 ms 204 KB correct
13 Correct 182 ms 204 KB correct
14 Runtime error 5 ms 460 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB correct
2 Runtime error 5 ms 332 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 54 ms 268 KB correct
2 Correct 596 ms 272 KB correct
3 Correct 697 ms 324 KB correct
4 Correct 2 ms 204 KB correct
5 Correct 1 ms 204 KB correct
6 Correct 14 ms 292 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 4 ms 204 KB correct
11 Correct 1 ms 204 KB correct
12 Correct 6 ms 204 KB correct
13 Correct 182 ms 204 KB correct
14 Runtime error 5 ms 460 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -