답안 #936326

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
936326 2024-03-01T15:40:09 Z Trisanu_Das Binaria (CCO23_day1problem1) C++17
25 / 25
97 ms 21332 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("0\n");
				return 0;
			}
		}
	}
	printf("%d\n", choose(k01, kk[0] - k1));
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |  scanf("%d%d", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |   scanf("%d", &kk[i]);
      |   ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 13660 KB Output is correct
2 Correct 8 ms 13816 KB Output is correct
3 Correct 8 ms 13660 KB Output is correct
4 Correct 8 ms 13660 KB Output is correct
5 Correct 9 ms 13660 KB Output is correct
6 Correct 8 ms 13660 KB Output is correct
7 Correct 8 ms 13868 KB Output is correct
8 Correct 8 ms 13660 KB Output is correct
9 Correct 8 ms 13660 KB Output is correct
10 Correct 8 ms 13660 KB Output is correct
11 Correct 8 ms 13868 KB Output is correct
12 Correct 8 ms 13660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 13660 KB Output is correct
2 Correct 8 ms 13816 KB Output is correct
3 Correct 8 ms 13660 KB Output is correct
4 Correct 8 ms 13660 KB Output is correct
5 Correct 9 ms 13660 KB Output is correct
6 Correct 8 ms 13660 KB Output is correct
7 Correct 8 ms 13868 KB Output is correct
8 Correct 8 ms 13660 KB Output is correct
9 Correct 8 ms 13660 KB Output is correct
10 Correct 8 ms 13660 KB Output is correct
11 Correct 8 ms 13868 KB Output is correct
12 Correct 8 ms 13660 KB Output is correct
13 Correct 8 ms 13660 KB Output is correct
14 Correct 8 ms 13868 KB Output is correct
15 Correct 8 ms 13660 KB Output is correct
16 Correct 8 ms 13660 KB Output is correct
17 Correct 9 ms 13660 KB Output is correct
18 Correct 8 ms 13660 KB Output is correct
19 Correct 8 ms 13772 KB Output is correct
20 Correct 8 ms 13660 KB Output is correct
21 Correct 8 ms 13660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 13660 KB Output is correct
2 Correct 8 ms 13816 KB Output is correct
3 Correct 8 ms 13660 KB Output is correct
4 Correct 8 ms 13660 KB Output is correct
5 Correct 9 ms 13660 KB Output is correct
6 Correct 8 ms 13660 KB Output is correct
7 Correct 8 ms 13868 KB Output is correct
8 Correct 8 ms 13660 KB Output is correct
9 Correct 8 ms 13660 KB Output is correct
10 Correct 8 ms 13660 KB Output is correct
11 Correct 8 ms 13868 KB Output is correct
12 Correct 8 ms 13660 KB Output is correct
13 Correct 8 ms 13660 KB Output is correct
14 Correct 8 ms 13868 KB Output is correct
15 Correct 8 ms 13660 KB Output is correct
16 Correct 8 ms 13660 KB Output is correct
17 Correct 9 ms 13660 KB Output is correct
18 Correct 8 ms 13660 KB Output is correct
19 Correct 8 ms 13772 KB Output is correct
20 Correct 8 ms 13660 KB Output is correct
21 Correct 8 ms 13660 KB Output is correct
22 Correct 8 ms 13660 KB Output is correct
23 Correct 8 ms 13872 KB Output is correct
24 Correct 8 ms 13660 KB Output is correct
25 Correct 9 ms 13660 KB Output is correct
26 Correct 8 ms 13660 KB Output is correct
27 Correct 9 ms 13656 KB Output is correct
28 Correct 8 ms 13660 KB Output is correct
29 Correct 8 ms 13660 KB Output is correct
30 Correct 9 ms 13860 KB Output is correct
31 Correct 8 ms 13660 KB Output is correct
32 Correct 8 ms 13660 KB Output is correct
33 Correct 8 ms 13660 KB Output is correct
34 Correct 9 ms 13660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 13660 KB Output is correct
2 Correct 8 ms 13816 KB Output is correct
3 Correct 8 ms 13660 KB Output is correct
4 Correct 8 ms 13660 KB Output is correct
5 Correct 9 ms 13660 KB Output is correct
6 Correct 8 ms 13660 KB Output is correct
7 Correct 8 ms 13868 KB Output is correct
8 Correct 8 ms 13660 KB Output is correct
9 Correct 8 ms 13660 KB Output is correct
10 Correct 8 ms 13660 KB Output is correct
11 Correct 8 ms 13868 KB Output is correct
12 Correct 8 ms 13660 KB Output is correct
13 Correct 8 ms 13660 KB Output is correct
14 Correct 8 ms 13868 KB Output is correct
15 Correct 8 ms 13660 KB Output is correct
16 Correct 8 ms 13660 KB Output is correct
17 Correct 9 ms 13660 KB Output is correct
18 Correct 8 ms 13660 KB Output is correct
19 Correct 8 ms 13772 KB Output is correct
20 Correct 8 ms 13660 KB Output is correct
21 Correct 8 ms 13660 KB Output is correct
22 Correct 8 ms 13660 KB Output is correct
23 Correct 8 ms 13872 KB Output is correct
24 Correct 8 ms 13660 KB Output is correct
25 Correct 9 ms 13660 KB Output is correct
26 Correct 8 ms 13660 KB Output is correct
27 Correct 9 ms 13656 KB Output is correct
28 Correct 8 ms 13660 KB Output is correct
29 Correct 8 ms 13660 KB Output is correct
30 Correct 9 ms 13860 KB Output is correct
31 Correct 8 ms 13660 KB Output is correct
32 Correct 8 ms 13660 KB Output is correct
33 Correct 8 ms 13660 KB Output is correct
34 Correct 9 ms 13660 KB Output is correct
35 Correct 71 ms 17960 KB Output is correct
36 Correct 73 ms 18516 KB Output is correct
37 Correct 73 ms 18772 KB Output is correct
38 Correct 75 ms 18840 KB Output is correct
39 Correct 69 ms 18004 KB Output is correct
40 Correct 76 ms 18836 KB Output is correct
41 Correct 74 ms 18836 KB Output is correct
42 Correct 72 ms 17952 KB Output is correct
43 Correct 71 ms 17936 KB Output is correct
44 Correct 72 ms 17812 KB Output is correct
45 Correct 72 ms 17816 KB Output is correct
46 Correct 70 ms 17812 KB Output is correct
47 Correct 78 ms 18004 KB Output is correct
48 Correct 74 ms 18956 KB Output is correct
49 Correct 74 ms 18772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 13660 KB Output is correct
2 Correct 8 ms 13816 KB Output is correct
3 Correct 8 ms 13660 KB Output is correct
4 Correct 8 ms 13660 KB Output is correct
5 Correct 9 ms 13660 KB Output is correct
6 Correct 8 ms 13660 KB Output is correct
7 Correct 8 ms 13868 KB Output is correct
8 Correct 8 ms 13660 KB Output is correct
9 Correct 8 ms 13660 KB Output is correct
10 Correct 8 ms 13660 KB Output is correct
11 Correct 8 ms 13868 KB Output is correct
12 Correct 8 ms 13660 KB Output is correct
13 Correct 8 ms 13660 KB Output is correct
14 Correct 8 ms 13868 KB Output is correct
15 Correct 8 ms 13660 KB Output is correct
16 Correct 8 ms 13660 KB Output is correct
17 Correct 9 ms 13660 KB Output is correct
18 Correct 8 ms 13660 KB Output is correct
19 Correct 8 ms 13772 KB Output is correct
20 Correct 8 ms 13660 KB Output is correct
21 Correct 8 ms 13660 KB Output is correct
22 Correct 8 ms 13660 KB Output is correct
23 Correct 8 ms 13872 KB Output is correct
24 Correct 8 ms 13660 KB Output is correct
25 Correct 9 ms 13660 KB Output is correct
26 Correct 8 ms 13660 KB Output is correct
27 Correct 9 ms 13656 KB Output is correct
28 Correct 8 ms 13660 KB Output is correct
29 Correct 8 ms 13660 KB Output is correct
30 Correct 9 ms 13860 KB Output is correct
31 Correct 8 ms 13660 KB Output is correct
32 Correct 8 ms 13660 KB Output is correct
33 Correct 8 ms 13660 KB Output is correct
34 Correct 9 ms 13660 KB Output is correct
35 Correct 71 ms 17960 KB Output is correct
36 Correct 73 ms 18516 KB Output is correct
37 Correct 73 ms 18772 KB Output is correct
38 Correct 75 ms 18840 KB Output is correct
39 Correct 69 ms 18004 KB Output is correct
40 Correct 76 ms 18836 KB Output is correct
41 Correct 74 ms 18836 KB Output is correct
42 Correct 72 ms 17952 KB Output is correct
43 Correct 71 ms 17936 KB Output is correct
44 Correct 72 ms 17812 KB Output is correct
45 Correct 72 ms 17816 KB Output is correct
46 Correct 70 ms 17812 KB Output is correct
47 Correct 78 ms 18004 KB Output is correct
48 Correct 74 ms 18956 KB Output is correct
49 Correct 74 ms 18772 KB Output is correct
50 Correct 97 ms 20820 KB Output is correct
51 Correct 79 ms 20820 KB Output is correct
52 Correct 77 ms 20816 KB Output is correct
53 Correct 77 ms 20888 KB Output is correct
54 Correct 81 ms 20820 KB Output is correct
55 Correct 79 ms 20820 KB Output is correct
56 Correct 81 ms 20892 KB Output is correct
57 Correct 78 ms 19796 KB Output is correct
58 Correct 79 ms 20888 KB Output is correct
59 Correct 78 ms 20820 KB Output is correct
60 Correct 80 ms 19960 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 13660 KB Output is correct
2 Correct 8 ms 13816 KB Output is correct
3 Correct 8 ms 13660 KB Output is correct
4 Correct 8 ms 13660 KB Output is correct
5 Correct 9 ms 13660 KB Output is correct
6 Correct 8 ms 13660 KB Output is correct
7 Correct 8 ms 13868 KB Output is correct
8 Correct 8 ms 13660 KB Output is correct
9 Correct 8 ms 13660 KB Output is correct
10 Correct 8 ms 13660 KB Output is correct
11 Correct 8 ms 13868 KB Output is correct
12 Correct 8 ms 13660 KB Output is correct
13 Correct 8 ms 13660 KB Output is correct
14 Correct 8 ms 13868 KB Output is correct
15 Correct 8 ms 13660 KB Output is correct
16 Correct 8 ms 13660 KB Output is correct
17 Correct 9 ms 13660 KB Output is correct
18 Correct 8 ms 13660 KB Output is correct
19 Correct 8 ms 13772 KB Output is correct
20 Correct 8 ms 13660 KB Output is correct
21 Correct 8 ms 13660 KB Output is correct
22 Correct 8 ms 13660 KB Output is correct
23 Correct 8 ms 13872 KB Output is correct
24 Correct 8 ms 13660 KB Output is correct
25 Correct 9 ms 13660 KB Output is correct
26 Correct 8 ms 13660 KB Output is correct
27 Correct 9 ms 13656 KB Output is correct
28 Correct 8 ms 13660 KB Output is correct
29 Correct 8 ms 13660 KB Output is correct
30 Correct 9 ms 13860 KB Output is correct
31 Correct 8 ms 13660 KB Output is correct
32 Correct 8 ms 13660 KB Output is correct
33 Correct 8 ms 13660 KB Output is correct
34 Correct 9 ms 13660 KB Output is correct
35 Correct 71 ms 17960 KB Output is correct
36 Correct 73 ms 18516 KB Output is correct
37 Correct 73 ms 18772 KB Output is correct
38 Correct 75 ms 18840 KB Output is correct
39 Correct 69 ms 18004 KB Output is correct
40 Correct 76 ms 18836 KB Output is correct
41 Correct 74 ms 18836 KB Output is correct
42 Correct 72 ms 17952 KB Output is correct
43 Correct 71 ms 17936 KB Output is correct
44 Correct 72 ms 17812 KB Output is correct
45 Correct 72 ms 17816 KB Output is correct
46 Correct 70 ms 17812 KB Output is correct
47 Correct 78 ms 18004 KB Output is correct
48 Correct 74 ms 18956 KB Output is correct
49 Correct 74 ms 18772 KB Output is correct
50 Correct 97 ms 20820 KB Output is correct
51 Correct 79 ms 20820 KB Output is correct
52 Correct 77 ms 20816 KB Output is correct
53 Correct 77 ms 20888 KB Output is correct
54 Correct 81 ms 20820 KB Output is correct
55 Correct 79 ms 20820 KB Output is correct
56 Correct 81 ms 20892 KB Output is correct
57 Correct 78 ms 19796 KB Output is correct
58 Correct 79 ms 20888 KB Output is correct
59 Correct 78 ms 20820 KB Output is correct
60 Correct 80 ms 19960 KB Output is correct
61 Correct 12 ms 14128 KB Output is correct
62 Correct 9 ms 13660 KB Output is correct
63 Correct 10 ms 13660 KB Output is correct
64 Correct 9 ms 13856 KB Output is correct
65 Correct 50 ms 19228 KB Output is correct
66 Correct 35 ms 16212 KB Output is correct
67 Correct 68 ms 21332 KB Output is correct
68 Correct 16 ms 14172 KB Output is correct
69 Correct 9 ms 13660 KB Output is correct
70 Correct 12 ms 13876 KB Output is correct
71 Correct 10 ms 13660 KB Output is correct