Submission #422790

# Submission time Handle Problem Language Result Execution time Memory
422790 2021-06-10T12:23:10 Z EJOI2019Andrew Simurgh (IOI17_simurgh) C++14
13 / 100
3000 ms 292 KB
#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
int p[22];
void initset(int x){
	for(int i=0;i<x;i++){
		p[i]=i;
	}
}
int finds(int u){
	if(u==p[u])
	return u;
	p[u]=finds(p[u]);
	return p[u];
}

int unionset(int u,int v){
	u=finds(u);
	v=finds(v);
	if(u!=v){
		 p[u]=v;
		 return 1;
	}
	return 0;
}
std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v){
	int tam=v.size();
	//int c=0;
	for(int i=0;i<(1<<tam);i++){
		if(__builtin_popcount(i)==n-1){
			vector<int> r;
			initset(n);
			int sw=0;
			for(ll j=0;j<tam;j++){
				if(i&(1<<j)){
					r.push_back(j);
					if(unionset(u[j],v[j])==0){
						sw=1;
						break;
					}
				}
			}
			//f.clear();
			if(sw==0){
					int common=count_common_roads(r);
					if(common==n-1){
						return r;
					}
					r.clear();
				}
			}
		}
	
}

Compilation message

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:56:1: warning: control reaches end of non-void function [-Wreturn-type]
   56 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 5 ms 204 KB correct
2 Correct 18 ms 204 KB correct
3 Correct 21 ms 204 KB correct
4 Correct 1 ms 204 KB correct
5 Correct 1 ms 204 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 288 KB correct
10 Correct 1 ms 204 KB correct
11 Correct 1 ms 204 KB correct
12 Correct 1 ms 292 KB correct
13 Correct 10 ms 288 KB correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 204 KB correct
2 Correct 18 ms 204 KB correct
3 Correct 21 ms 204 KB correct
4 Correct 1 ms 204 KB correct
5 Correct 1 ms 204 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 288 KB correct
10 Correct 1 ms 204 KB correct
11 Correct 1 ms 204 KB correct
12 Correct 1 ms 292 KB correct
13 Correct 10 ms 288 KB correct
14 Execution timed out 3069 ms 204 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 204 KB correct
2 Correct 18 ms 204 KB correct
3 Correct 21 ms 204 KB correct
4 Correct 1 ms 204 KB correct
5 Correct 1 ms 204 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 288 KB correct
10 Correct 1 ms 204 KB correct
11 Correct 1 ms 204 KB correct
12 Correct 1 ms 292 KB correct
13 Correct 10 ms 288 KB correct
14 Execution timed out 3069 ms 204 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB correct
2 Execution timed out 3060 ms 204 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 204 KB correct
2 Correct 18 ms 204 KB correct
3 Correct 21 ms 204 KB correct
4 Correct 1 ms 204 KB correct
5 Correct 1 ms 204 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 288 KB correct
10 Correct 1 ms 204 KB correct
11 Correct 1 ms 204 KB correct
12 Correct 1 ms 292 KB correct
13 Correct 10 ms 288 KB correct
14 Execution timed out 3069 ms 204 KB Time limit exceeded
15 Halted 0 ms 0 KB -