답안 #823170

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
823170 2023-08-12T08:46:24 Z rainboy Binaria (CCO23_day1problem1) C
25 / 25
119 ms 20400 KB
#include <stdio.h>

#define N	1000000
#define MD	1000003

int vv[N + 1], ff[N + 1], gg[N + 1];

void init() {
	int i;

	ff[0] = gg[0] = 1;
	for (i = 1; i <= N; i++) {
		vv[i] = i == 1 ? 1 : (long long) vv[i - MD % i] * (MD / i + 1) % MD;
		ff[i] = (long long) ff[i - 1] * i % MD;
		gg[i] = (long long) gg[i - 1] * vv[i] % MD;
	}
}

int choose(int n, int k) {
	return k < 0 || k > n ? 0 : (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;
}

int main() {
	static int kk[N];
	int n, k, i, r, a, k1, k01;

	init();
	scanf("%d%d", &n, &k);
	for (i = 0; i + k <= n; i++)
		scanf("%d", &kk[i]);
	k01 = k1 = 0;
	for (r = 0; r < k; r++) {
		a = -1;
		for (i = r; i + k < n; i += k)
			if (kk[i + 1] != kk[i]) {
				if (kk[i + 1] - kk[i] == 1)
					a = 0;
				else if (kk[i + 1] - kk[i] == -1)
					a = 1;
				else
					a = -2;
				break;
			}
		if (a == -2) {
			printf("0\n");
			return 0;
		}
		if (a == -1) {
			k01++;
			continue;
		}
		if (a == 1)
			k1++;
		for (i = r; i + k < n; i += k) {
			a += kk[i + 1] - kk[i];
			if (a != 0 && a != 1) {
				printf("01\n");
				return 0;
			}
		}
	}
	printf("%d\n", choose(k01, kk[0] - k1));
	return 0;
}

Compilation message

Main.c: In function 'main':
Main.c:28:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |  scanf("%d%d", &n, &k);
      |  ^~~~~~~~~~~~~~~~~~~~~
Main.c:30:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |   scanf("%d", &kk[i]);
      |   ^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 11988 KB Output is correct
2 Correct 14 ms 11940 KB Output is correct
3 Correct 11 ms 12000 KB Output is correct
4 Correct 14 ms 11988 KB Output is correct
5 Correct 10 ms 12012 KB Output is correct
6 Correct 14 ms 11988 KB Output is correct
7 Correct 11 ms 11960 KB Output is correct
8 Correct 11 ms 11988 KB Output is correct
9 Correct 13 ms 11988 KB Output is correct
10 Correct 10 ms 11940 KB Output is correct
11 Correct 10 ms 11936 KB Output is correct
12 Correct 10 ms 11988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 11988 KB Output is correct
2 Correct 14 ms 11940 KB Output is correct
3 Correct 11 ms 12000 KB Output is correct
4 Correct 14 ms 11988 KB Output is correct
5 Correct 10 ms 12012 KB Output is correct
6 Correct 14 ms 11988 KB Output is correct
7 Correct 11 ms 11960 KB Output is correct
8 Correct 11 ms 11988 KB Output is correct
9 Correct 13 ms 11988 KB Output is correct
10 Correct 10 ms 11940 KB Output is correct
11 Correct 10 ms 11936 KB Output is correct
12 Correct 10 ms 11988 KB Output is correct
13 Correct 11 ms 11916 KB Output is correct
14 Correct 12 ms 11988 KB Output is correct
15 Correct 14 ms 11976 KB Output is correct
16 Correct 14 ms 12028 KB Output is correct
17 Correct 12 ms 11944 KB Output is correct
18 Correct 10 ms 11988 KB Output is correct
19 Correct 12 ms 11988 KB Output is correct
20 Correct 13 ms 12004 KB Output is correct
21 Correct 11 ms 12012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 11988 KB Output is correct
2 Correct 14 ms 11940 KB Output is correct
3 Correct 11 ms 12000 KB Output is correct
4 Correct 14 ms 11988 KB Output is correct
5 Correct 10 ms 12012 KB Output is correct
6 Correct 14 ms 11988 KB Output is correct
7 Correct 11 ms 11960 KB Output is correct
8 Correct 11 ms 11988 KB Output is correct
9 Correct 13 ms 11988 KB Output is correct
10 Correct 10 ms 11940 KB Output is correct
11 Correct 10 ms 11936 KB Output is correct
12 Correct 10 ms 11988 KB Output is correct
13 Correct 11 ms 11916 KB Output is correct
14 Correct 12 ms 11988 KB Output is correct
15 Correct 14 ms 11976 KB Output is correct
16 Correct 14 ms 12028 KB Output is correct
17 Correct 12 ms 11944 KB Output is correct
18 Correct 10 ms 11988 KB Output is correct
19 Correct 12 ms 11988 KB Output is correct
20 Correct 13 ms 12004 KB Output is correct
21 Correct 11 ms 12012 KB Output is correct
22 Correct 10 ms 12000 KB Output is correct
23 Correct 14 ms 12012 KB Output is correct
24 Correct 11 ms 11988 KB Output is correct
25 Correct 10 ms 11988 KB Output is correct
26 Correct 12 ms 12020 KB Output is correct
27 Correct 12 ms 11984 KB Output is correct
28 Correct 10 ms 11964 KB Output is correct
29 Correct 10 ms 12024 KB Output is correct
30 Correct 11 ms 11984 KB Output is correct
31 Correct 11 ms 11936 KB Output is correct
32 Correct 11 ms 11936 KB Output is correct
33 Correct 11 ms 12004 KB Output is correct
34 Correct 11 ms 12024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 11988 KB Output is correct
2 Correct 14 ms 11940 KB Output is correct
3 Correct 11 ms 12000 KB Output is correct
4 Correct 14 ms 11988 KB Output is correct
5 Correct 10 ms 12012 KB Output is correct
6 Correct 14 ms 11988 KB Output is correct
7 Correct 11 ms 11960 KB Output is correct
8 Correct 11 ms 11988 KB Output is correct
9 Correct 13 ms 11988 KB Output is correct
10 Correct 10 ms 11940 KB Output is correct
11 Correct 10 ms 11936 KB Output is correct
12 Correct 10 ms 11988 KB Output is correct
13 Correct 11 ms 11916 KB Output is correct
14 Correct 12 ms 11988 KB Output is correct
15 Correct 14 ms 11976 KB Output is correct
16 Correct 14 ms 12028 KB Output is correct
17 Correct 12 ms 11944 KB Output is correct
18 Correct 10 ms 11988 KB Output is correct
19 Correct 12 ms 11988 KB Output is correct
20 Correct 13 ms 12004 KB Output is correct
21 Correct 11 ms 12012 KB Output is correct
22 Correct 10 ms 12000 KB Output is correct
23 Correct 14 ms 12012 KB Output is correct
24 Correct 11 ms 11988 KB Output is correct
25 Correct 10 ms 11988 KB Output is correct
26 Correct 12 ms 12020 KB Output is correct
27 Correct 12 ms 11984 KB Output is correct
28 Correct 10 ms 11964 KB Output is correct
29 Correct 10 ms 12024 KB Output is correct
30 Correct 11 ms 11984 KB Output is correct
31 Correct 11 ms 11936 KB Output is correct
32 Correct 11 ms 11936 KB Output is correct
33 Correct 11 ms 12004 KB Output is correct
34 Correct 11 ms 12024 KB Output is correct
35 Correct 73 ms 17640 KB Output is correct
36 Correct 80 ms 18384 KB Output is correct
37 Correct 104 ms 18180 KB Output is correct
38 Correct 106 ms 18024 KB Output is correct
39 Correct 80 ms 17168 KB Output is correct
40 Correct 80 ms 18612 KB Output is correct
41 Correct 74 ms 18236 KB Output is correct
42 Correct 97 ms 17528 KB Output is correct
43 Correct 100 ms 17188 KB Output is correct
44 Correct 100 ms 17628 KB Output is correct
45 Correct 90 ms 17324 KB Output is correct
46 Correct 78 ms 17376 KB Output is correct
47 Correct 67 ms 17524 KB Output is correct
48 Correct 86 ms 18456 KB Output is correct
49 Correct 78 ms 18276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 11988 KB Output is correct
2 Correct 14 ms 11940 KB Output is correct
3 Correct 11 ms 12000 KB Output is correct
4 Correct 14 ms 11988 KB Output is correct
5 Correct 10 ms 12012 KB Output is correct
6 Correct 14 ms 11988 KB Output is correct
7 Correct 11 ms 11960 KB Output is correct
8 Correct 11 ms 11988 KB Output is correct
9 Correct 13 ms 11988 KB Output is correct
10 Correct 10 ms 11940 KB Output is correct
11 Correct 10 ms 11936 KB Output is correct
12 Correct 10 ms 11988 KB Output is correct
13 Correct 11 ms 11916 KB Output is correct
14 Correct 12 ms 11988 KB Output is correct
15 Correct 14 ms 11976 KB Output is correct
16 Correct 14 ms 12028 KB Output is correct
17 Correct 12 ms 11944 KB Output is correct
18 Correct 10 ms 11988 KB Output is correct
19 Correct 12 ms 11988 KB Output is correct
20 Correct 13 ms 12004 KB Output is correct
21 Correct 11 ms 12012 KB Output is correct
22 Correct 10 ms 12000 KB Output is correct
23 Correct 14 ms 12012 KB Output is correct
24 Correct 11 ms 11988 KB Output is correct
25 Correct 10 ms 11988 KB Output is correct
26 Correct 12 ms 12020 KB Output is correct
27 Correct 12 ms 11984 KB Output is correct
28 Correct 10 ms 11964 KB Output is correct
29 Correct 10 ms 12024 KB Output is correct
30 Correct 11 ms 11984 KB Output is correct
31 Correct 11 ms 11936 KB Output is correct
32 Correct 11 ms 11936 KB Output is correct
33 Correct 11 ms 12004 KB Output is correct
34 Correct 11 ms 12024 KB Output is correct
35 Correct 73 ms 17640 KB Output is correct
36 Correct 80 ms 18384 KB Output is correct
37 Correct 104 ms 18180 KB Output is correct
38 Correct 106 ms 18024 KB Output is correct
39 Correct 80 ms 17168 KB Output is correct
40 Correct 80 ms 18612 KB Output is correct
41 Correct 74 ms 18236 KB Output is correct
42 Correct 97 ms 17528 KB Output is correct
43 Correct 100 ms 17188 KB Output is correct
44 Correct 100 ms 17628 KB Output is correct
45 Correct 90 ms 17324 KB Output is correct
46 Correct 78 ms 17376 KB Output is correct
47 Correct 67 ms 17524 KB Output is correct
48 Correct 86 ms 18456 KB Output is correct
49 Correct 78 ms 18276 KB Output is correct
50 Correct 117 ms 19292 KB Output is correct
51 Correct 95 ms 18132 KB Output is correct
52 Correct 103 ms 19884 KB Output is correct
53 Correct 112 ms 20104 KB Output is correct
54 Correct 87 ms 20400 KB Output is correct
55 Correct 115 ms 19356 KB Output is correct
56 Correct 119 ms 20256 KB Output is correct
57 Correct 79 ms 19320 KB Output is correct
58 Correct 100 ms 20040 KB Output is correct
59 Correct 103 ms 19392 KB Output is correct
60 Correct 77 ms 19692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 11988 KB Output is correct
2 Correct 14 ms 11940 KB Output is correct
3 Correct 11 ms 12000 KB Output is correct
4 Correct 14 ms 11988 KB Output is correct
5 Correct 10 ms 12012 KB Output is correct
6 Correct 14 ms 11988 KB Output is correct
7 Correct 11 ms 11960 KB Output is correct
8 Correct 11 ms 11988 KB Output is correct
9 Correct 13 ms 11988 KB Output is correct
10 Correct 10 ms 11940 KB Output is correct
11 Correct 10 ms 11936 KB Output is correct
12 Correct 10 ms 11988 KB Output is correct
13 Correct 11 ms 11916 KB Output is correct
14 Correct 12 ms 11988 KB Output is correct
15 Correct 14 ms 11976 KB Output is correct
16 Correct 14 ms 12028 KB Output is correct
17 Correct 12 ms 11944 KB Output is correct
18 Correct 10 ms 11988 KB Output is correct
19 Correct 12 ms 11988 KB Output is correct
20 Correct 13 ms 12004 KB Output is correct
21 Correct 11 ms 12012 KB Output is correct
22 Correct 10 ms 12000 KB Output is correct
23 Correct 14 ms 12012 KB Output is correct
24 Correct 11 ms 11988 KB Output is correct
25 Correct 10 ms 11988 KB Output is correct
26 Correct 12 ms 12020 KB Output is correct
27 Correct 12 ms 11984 KB Output is correct
28 Correct 10 ms 11964 KB Output is correct
29 Correct 10 ms 12024 KB Output is correct
30 Correct 11 ms 11984 KB Output is correct
31 Correct 11 ms 11936 KB Output is correct
32 Correct 11 ms 11936 KB Output is correct
33 Correct 11 ms 12004 KB Output is correct
34 Correct 11 ms 12024 KB Output is correct
35 Correct 73 ms 17640 KB Output is correct
36 Correct 80 ms 18384 KB Output is correct
37 Correct 104 ms 18180 KB Output is correct
38 Correct 106 ms 18024 KB Output is correct
39 Correct 80 ms 17168 KB Output is correct
40 Correct 80 ms 18612 KB Output is correct
41 Correct 74 ms 18236 KB Output is correct
42 Correct 97 ms 17528 KB Output is correct
43 Correct 100 ms 17188 KB Output is correct
44 Correct 100 ms 17628 KB Output is correct
45 Correct 90 ms 17324 KB Output is correct
46 Correct 78 ms 17376 KB Output is correct
47 Correct 67 ms 17524 KB Output is correct
48 Correct 86 ms 18456 KB Output is correct
49 Correct 78 ms 18276 KB Output is correct
50 Correct 117 ms 19292 KB Output is correct
51 Correct 95 ms 18132 KB Output is correct
52 Correct 103 ms 19884 KB Output is correct
53 Correct 112 ms 20104 KB Output is correct
54 Correct 87 ms 20400 KB Output is correct
55 Correct 115 ms 19356 KB Output is correct
56 Correct 119 ms 20256 KB Output is correct
57 Correct 79 ms 19320 KB Output is correct
58 Correct 100 ms 20040 KB Output is correct
59 Correct 103 ms 19392 KB Output is correct
60 Correct 77 ms 19692 KB Output is correct
61 Correct 11 ms 11940 KB Output is correct
62 Correct 16 ms 11948 KB Output is correct
63 Correct 11 ms 11988 KB Output is correct
64 Correct 12 ms 11976 KB Output is correct
65 Correct 54 ms 16940 KB Output is correct
66 Correct 44 ms 14620 KB Output is correct
67 Correct 69 ms 20256 KB Output is correct
68 Correct 18 ms 12804 KB Output is correct
69 Correct 11 ms 12032 KB Output is correct
70 Correct 12 ms 11988 KB Output is correct
71 Correct 11 ms 11988 KB Output is correct