Submission #128431

# Submission time Handle Problem Language Result Execution time Memory
128431 2019-07-10T22:39:42 Z chubyxdxd Simurgh (IOI17_simurgh) C++11
13 / 100
28 ms 396 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];
}
/*bool issameset(int u,int v){
	return find(u)==find(v);
}*/
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();
				}
			}
		}
	//return r;
	//int common=count_common_roads(r);
}

Compilation message

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:59:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 8 ms 376 KB correct
2 Correct 26 ms 376 KB correct
3 Correct 28 ms 376 KB correct
4 Correct 2 ms 376 KB correct
5 Correct 2 ms 256 KB correct
6 Correct 4 ms 376 KB correct
7 Correct 2 ms 376 KB correct
8 Correct 2 ms 380 KB correct
9 Correct 2 ms 376 KB correct
10 Correct 3 ms 376 KB correct
11 Correct 12 ms 376 KB correct
12 Correct 3 ms 256 KB correct
13 Correct 13 ms 396 KB correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 376 KB correct
2 Correct 26 ms 376 KB correct
3 Correct 28 ms 376 KB correct
4 Correct 2 ms 376 KB correct
5 Correct 2 ms 256 KB correct
6 Correct 4 ms 376 KB correct
7 Correct 2 ms 376 KB correct
8 Correct 2 ms 380 KB correct
9 Correct 2 ms 376 KB correct
10 Correct 3 ms 376 KB correct
11 Correct 12 ms 376 KB correct
12 Correct 3 ms 256 KB correct
13 Correct 13 ms 396 KB correct
14 Incorrect 2 ms 376 KB WA in grader: NO
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 376 KB correct
2 Correct 26 ms 376 KB correct
3 Correct 28 ms 376 KB correct
4 Correct 2 ms 376 KB correct
5 Correct 2 ms 256 KB correct
6 Correct 4 ms 376 KB correct
7 Correct 2 ms 376 KB correct
8 Correct 2 ms 380 KB correct
9 Correct 2 ms 376 KB correct
10 Correct 3 ms 376 KB correct
11 Correct 12 ms 376 KB correct
12 Correct 3 ms 256 KB correct
13 Correct 13 ms 396 KB correct
14 Incorrect 2 ms 376 KB WA in grader: NO
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB correct
2 Incorrect 2 ms 256 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 376 KB correct
2 Correct 26 ms 376 KB correct
3 Correct 28 ms 376 KB correct
4 Correct 2 ms 376 KB correct
5 Correct 2 ms 256 KB correct
6 Correct 4 ms 376 KB correct
7 Correct 2 ms 376 KB correct
8 Correct 2 ms 380 KB correct
9 Correct 2 ms 376 KB correct
10 Correct 3 ms 376 KB correct
11 Correct 12 ms 376 KB correct
12 Correct 3 ms 256 KB correct
13 Correct 13 ms 396 KB correct
14 Incorrect 2 ms 376 KB WA in grader: NO
15 Halted 0 ms 0 KB -