Submission #19676

# Submission time Handle Problem Language Result Execution time Memory
19676 2016-02-25T04:26:56 Z hongjun7 트리 (kriii4_X) C++
9 / 100
97 ms 1084 KB
#include <stdio.h>
#include <algorithm>
using namespace std;
int n, m, par[10], a[10], b[10], c[10], res;
void f(int x) {
	c[x] = 1;
	for (int i = 1; i <= n; i++) {
		if (par[i] == x) {
			f(i);
		}
	}
}
void go(int x) {
	if (x == n + 1) {
		for (int i = 1; i <= n; i++) c[i] = 0;
		f(1);
		bool ok = 1;
		for (int i = 1; i <= n; i++) if (c[i] == 0) ok = 0;
		for (int i = 1; i <= m; i++) if (!(par[a[i]] == b[i] || par[b[i]] == a[i])) ok = 0;
		if (ok) res++;
		return;
	}
	if (x == 1) {
		par[x] = 0;
		go(x + 1);
	}
	else {
		for (int i = 1; i <= n; i++) {
			if (i == x) continue;
			par[x] = i;
			go(x + 1);
		}
	}
}
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++) scanf("%d%d", &a[i], &b[i]);
	res = 0;
	go(1);
	printf("%d", res);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1084 KB Output is correct
2 Correct 0 ms 1084 KB Output is correct
3 Correct 0 ms 1084 KB Output is correct
4 Correct 0 ms 1084 KB Output is correct
5 Correct 0 ms 1084 KB Output is correct
6 Correct 0 ms 1084 KB Output is correct
7 Correct 5 ms 1084 KB Output is correct
8 Correct 87 ms 1084 KB Output is correct
9 Correct 96 ms 1084 KB Output is correct
10 Correct 97 ms 1084 KB Output is correct
11 Correct 91 ms 1084 KB Output is correct
12 Correct 93 ms 1084 KB Output is correct
13 Correct 5 ms 1084 KB Output is correct
14 Correct 0 ms 1084 KB Output is correct
15 Correct 89 ms 1084 KB Output is correct
16 Correct 5 ms 1084 KB Output is correct
17 Correct 0 ms 1084 KB Output is correct
18 Correct 91 ms 1084 KB Output is correct
19 Correct 5 ms 1084 KB Output is correct
20 Correct 0 ms 1084 KB Output is correct
21 Correct 5 ms 1084 KB Output is correct
22 Correct 94 ms 1084 KB Output is correct
23 Correct 5 ms 1084 KB Output is correct
24 Correct 90 ms 1084 KB Output is correct
25 Correct 95 ms 1084 KB Output is correct
26 Correct 91 ms 1084 KB Output is correct
27 Correct 5 ms 1084 KB Output is correct
28 Correct 0 ms 1084 KB Output is correct
29 Correct 0 ms 1084 KB Output is correct
30 Correct 5 ms 1084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 1080 KB futex (syscall #202) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -