답안 #544741

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
544741 2022-04-02T16:18:15 Z rainboy Paths (BOI18_paths) C
100 / 100
282 ms 43500 KB
#include <stdio.h>

#define N	300000
#define M	300000
#define K	5

int main() {
	static int cc[N], ii[M], jj[M];
	static long long dp[1 << K][N];
	int n, m, k, h, i, j, b;
	long long ans;

	scanf("%d%d%d", &n, &m, &k);
	for (i = 0; i < n; i++)
		scanf("%d", &cc[i]), cc[i]--;
	for (h = 0; h < m; h++)
		scanf("%d%d", &ii[h], &jj[h]), ii[h]--, jj[h]--;
	for (i = 0; i < n; i++)
		dp[1 << cc[i]][i] = 1;
	for (b = 0; b < 1 << k; b++)
		for (h = 0; h < m; h++) {
			i = ii[h], j = jj[h];
			if (!(b & 1 << cc[j]))
				dp[b | 1 << cc[j]][j] += dp[b][i];
			if (!(b & 1 << cc[i]))
				dp[b | 1 << cc[i]][i] += dp[b][j];
		}
	ans = 0;
	for (b = 0; b < 1 << k; b++)
		if (b & b - 1)
			for (i = 0; i < n; i++)
				ans += dp[b][i];
	printf("%lld\n", ans);
	return 0;
}

Compilation message

paths.c: In function 'main':
paths.c:30:13: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   30 |   if (b & b - 1)
      |           ~~^~~
paths.c:13:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d%d%d", &n, &m, &k);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
paths.c:15:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   scanf("%d", &cc[i]), cc[i]--;
      |   ^~~~~~~~~~~~~~~~~~~
paths.c:17:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |   scanf("%d%d", &ii[h], &jj[h]), ii[h]--, jj[h]--;
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 432 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 92 ms 5712 KB Output is correct
2 Correct 85 ms 4980 KB Output is correct
3 Correct 191 ms 24700 KB Output is correct
4 Correct 94 ms 6812 KB Output is correct
5 Correct 86 ms 6332 KB Output is correct
6 Correct 136 ms 18412 KB Output is correct
7 Correct 179 ms 24652 KB Output is correct
8 Correct 191 ms 24712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 432 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 92 ms 5712 KB Output is correct
12 Correct 85 ms 4980 KB Output is correct
13 Correct 191 ms 24700 KB Output is correct
14 Correct 94 ms 6812 KB Output is correct
15 Correct 86 ms 6332 KB Output is correct
16 Correct 136 ms 18412 KB Output is correct
17 Correct 179 ms 24652 KB Output is correct
18 Correct 191 ms 24712 KB Output is correct
19 Correct 90 ms 5708 KB Output is correct
20 Correct 83 ms 4964 KB Output is correct
21 Correct 206 ms 24712 KB Output is correct
22 Correct 90 ms 6828 KB Output is correct
23 Correct 74 ms 6308 KB Output is correct
24 Correct 140 ms 18436 KB Output is correct
25 Correct 194 ms 24800 KB Output is correct
26 Correct 170 ms 24596 KB Output is correct
27 Correct 125 ms 5008 KB Output is correct
28 Correct 142 ms 6680 KB Output is correct
29 Correct 256 ms 43468 KB Output is correct
30 Correct 206 ms 24988 KB Output is correct
31 Correct 196 ms 23604 KB Output is correct
32 Correct 282 ms 43500 KB Output is correct
33 Correct 1 ms 360 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 288 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 0 ms 292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 63 ms 2120 KB Output is correct
3 Correct 32 ms 1872 KB Output is correct
4 Correct 52 ms 8340 KB Output is correct
5 Correct 44 ms 8296 KB Output is correct
6 Correct 114 ms 27288 KB Output is correct
7 Correct 38 ms 1964 KB Output is correct
8 Correct 80 ms 14568 KB Output is correct
9 Correct 71 ms 14616 KB Output is correct
10 Correct 71 ms 13840 KB Output is correct
11 Correct 77 ms 14668 KB Output is correct
12 Correct 87 ms 19488 KB Output is correct
13 Correct 85 ms 13600 KB Output is correct
14 Correct 114 ms 27296 KB Output is correct
15 Correct 118 ms 27192 KB Output is correct
16 Correct 1 ms 424 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 292 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 416 KB Output is correct
23 Correct 1 ms 420 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct