답안 #72677

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72677 2018-08-26T14:08:40 Z mhnd Simurgh (IOI17_simurgh) C++14
13 / 100
35 ms 544 KB
#include "simurgh.h"
using namespace std;
const int MAX = 7;
int par[MAX];
int find(int v)
{
	return (par[v] == v ? v : par[v] = find(par[v]));
}
bool merge(int u, int v)
{
	u = find(u);
	v = find(v);
	if (u == v)
		return false;
	par[u] = v;
	return true;
}
vector<int> find_roads(int n, vector<int> u, vector<int> v) {
	int m = v.size();
	for (int mask = 0; mask < (1 << m); mask++)
		if (__builtin_popcount(mask) == n - 1)
		{
			for (int i = 0; i < n; i++)
				par[i] = i;
			bool valid = true;
			vector<int> edges;
			for (int i = 0; i < m; i++)
				if ((1 << i) & mask)
				{
					edges.push_back(i);
					valid &= merge(u[i], v[i]);
				}
			if (valid && count_common_roads(edges) == n-1)
				return edges;
		}
}

Compilation message

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:36:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 248 KB correct
2 Correct 33 ms 356 KB correct
3 Correct 35 ms 392 KB correct
4 Correct 3 ms 392 KB correct
5 Correct 2 ms 440 KB correct
6 Correct 5 ms 468 KB correct
7 Correct 2 ms 468 KB correct
8 Correct 2 ms 468 KB correct
9 Correct 2 ms 468 KB correct
10 Correct 3 ms 468 KB correct
11 Correct 3 ms 468 KB correct
12 Correct 3 ms 468 KB correct
13 Correct 19 ms 468 KB correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 248 KB correct
2 Correct 33 ms 356 KB correct
3 Correct 35 ms 392 KB correct
4 Correct 3 ms 392 KB correct
5 Correct 2 ms 440 KB correct
6 Correct 5 ms 468 KB correct
7 Correct 2 ms 468 KB correct
8 Correct 2 ms 468 KB correct
9 Correct 2 ms 468 KB correct
10 Correct 3 ms 468 KB correct
11 Correct 3 ms 468 KB correct
12 Correct 3 ms 468 KB correct
13 Correct 19 ms 468 KB correct
14 Incorrect 2 ms 544 KB WA in grader: NO
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 248 KB correct
2 Correct 33 ms 356 KB correct
3 Correct 35 ms 392 KB correct
4 Correct 3 ms 392 KB correct
5 Correct 2 ms 440 KB correct
6 Correct 5 ms 468 KB correct
7 Correct 2 ms 468 KB correct
8 Correct 2 ms 468 KB correct
9 Correct 2 ms 468 KB correct
10 Correct 3 ms 468 KB correct
11 Correct 3 ms 468 KB correct
12 Correct 3 ms 468 KB correct
13 Correct 19 ms 468 KB correct
14 Incorrect 2 ms 544 KB WA in grader: NO
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 544 KB correct
2 Incorrect 4 ms 544 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 248 KB correct
2 Correct 33 ms 356 KB correct
3 Correct 35 ms 392 KB correct
4 Correct 3 ms 392 KB correct
5 Correct 2 ms 440 KB correct
6 Correct 5 ms 468 KB correct
7 Correct 2 ms 468 KB correct
8 Correct 2 ms 468 KB correct
9 Correct 2 ms 468 KB correct
10 Correct 3 ms 468 KB correct
11 Correct 3 ms 468 KB correct
12 Correct 3 ms 468 KB correct
13 Correct 19 ms 468 KB correct
14 Incorrect 2 ms 544 KB WA in grader: NO
15 Halted 0 ms 0 KB -