# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
932849 | 2024-02-24T10:07:52 Z | Son | Binaria (CCO23_day1problem1) | C++14 | 304 ms | 21052 KB |
#include <bits/stdc++.h> using namespace std; #define LL long long #define pb push_back #define fi first #define se second #define mp make_pair int n,k; int A[1000005]; int fact[1000005], inv[1000005]; int mo = 1e6 + 3; int B[1000005]; int expo( int a, int b ){ if ( b == 0 ) return 1; int half = expo(a,b/2); half = ( 1LL * half * half ) % mo; if ( b & 1 ){ half = ( 1LL * half * a ) % mo; } return half; } int C( int N, int K ){ if ( K > N || K < 0 ) return 0; int ans = (fact[N] * 1LL * inv[K]) % mo; ans = ( ans * 1LL * inv[N-K] ) % mo; return ans; } void fail(){ printf("0\n"); exit(0); } int main(){ scanf("%d%d",&n,&k); for ( int i = 1; i <= n-k+1; i++ ){ scanf("%d",&A[i]); } fact[0] = inv[0] = 1; for ( int i = 1; i <= n; i++ ){ fact[i] = ( fact[i-1] * 1LL * i ) % mo; inv[i] = expo(fact[i], mo - 2) % mo; B[i] = 2; } for ( int i = n-k; i >= 1; i-- ){ if ( abs(A[i] - A[i+1]) > 1 ){ fail(); } if ( A[i] > A[i+1] ){ if ( B[i+k] == 1 ){ fail(); } B[i] = 1; } else if ( A[i] < A[i+1] ){ if ( B[i+k] == 0 ){ fail(); } B[i] = 0; } else { B[i] = B[i+k]; } } int N = 0, K = A[1]; for ( int i = 1; i <= k; i++ ){ if ( B[i] == 1 ){ K--; } if ( B[i] == 2 ){ N++; } } printf("%d\n",C(N,K)); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 6492 KB | Output is correct |
2 | Correct | 1 ms | 6588 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 6488 KB | Output is correct |
9 | Correct | 2 ms | 6492 KB | Output is correct |
10 | Correct | 1 ms | 440 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 6492 KB | Output is correct |
2 | Correct | 1 ms | 6588 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 6488 KB | Output is correct |
9 | Correct | 2 ms | 6492 KB | Output is correct |
10 | Correct | 1 ms | 440 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 360 KB | Output is correct |
15 | Correct | 1 ms | 6492 KB | Output is correct |
16 | Correct | 1 ms | 6492 KB | Output is correct |
17 | Correct | 2 ms | 6492 KB | Output is correct |
18 | Correct | 1 ms | 344 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 6492 KB | Output is correct |
2 | Correct | 1 ms | 6588 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 6488 KB | Output is correct |
9 | Correct | 2 ms | 6492 KB | Output is correct |
10 | Correct | 1 ms | 440 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 360 KB | Output is correct |
15 | Correct | 1 ms | 6492 KB | Output is correct |
16 | Correct | 1 ms | 6492 KB | Output is correct |
17 | Correct | 2 ms | 6492 KB | Output is correct |
18 | Correct | 1 ms | 344 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 348 KB | Output is correct |
22 | Correct | 1 ms | 6492 KB | Output is correct |
23 | Correct | 1 ms | 6492 KB | Output is correct |
24 | Correct | 1 ms | 348 KB | Output is correct |
25 | Correct | 1 ms | 348 KB | Output is correct |
26 | Correct | 1 ms | 348 KB | Output is correct |
27 | Correct | 1 ms | 348 KB | Output is correct |
28 | Correct | 1 ms | 6492 KB | Output is correct |
29 | Correct | 2 ms | 6492 KB | Output is correct |
30 | Correct | 2 ms | 6492 KB | Output is correct |
31 | Correct | 1 ms | 344 KB | Output is correct |
32 | Correct | 1 ms | 344 KB | Output is correct |
33 | Correct | 1 ms | 348 KB | Output is correct |
34 | Correct | 1 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 6492 KB | Output is correct |
2 | Correct | 1 ms | 6588 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 6488 KB | Output is correct |
9 | Correct | 2 ms | 6492 KB | Output is correct |
10 | Correct | 1 ms | 440 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 360 KB | Output is correct |
15 | Correct | 1 ms | 6492 KB | Output is correct |
16 | Correct | 1 ms | 6492 KB | Output is correct |
17 | Correct | 2 ms | 6492 KB | Output is correct |
18 | Correct | 1 ms | 344 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 348 KB | Output is correct |
22 | Correct | 1 ms | 6492 KB | Output is correct |
23 | Correct | 1 ms | 6492 KB | Output is correct |
24 | Correct | 1 ms | 348 KB | Output is correct |
25 | Correct | 1 ms | 348 KB | Output is correct |
26 | Correct | 1 ms | 348 KB | Output is correct |
27 | Correct | 1 ms | 348 KB | Output is correct |
28 | Correct | 1 ms | 6492 KB | Output is correct |
29 | Correct | 2 ms | 6492 KB | Output is correct |
30 | Correct | 2 ms | 6492 KB | Output is correct |
31 | Correct | 1 ms | 344 KB | Output is correct |
32 | Correct | 1 ms | 344 KB | Output is correct |
33 | Correct | 1 ms | 348 KB | Output is correct |
34 | Correct | 1 ms | 348 KB | Output is correct |
35 | Correct | 265 ms | 17920 KB | Output is correct |
36 | Correct | 276 ms | 18660 KB | Output is correct |
37 | Correct | 271 ms | 18876 KB | Output is correct |
38 | Correct | 264 ms | 18764 KB | Output is correct |
39 | Correct | 264 ms | 18028 KB | Output is correct |
40 | Correct | 264 ms | 18768 KB | Output is correct |
41 | Correct | 264 ms | 18840 KB | Output is correct |
42 | Correct | 260 ms | 18024 KB | Output is correct |
43 | Correct | 265 ms | 18000 KB | Output is correct |
44 | Correct | 268 ms | 17964 KB | Output is correct |
45 | Correct | 263 ms | 18000 KB | Output is correct |
46 | Correct | 262 ms | 18004 KB | Output is correct |
47 | Correct | 293 ms | 18004 KB | Output is correct |
48 | Correct | 266 ms | 18880 KB | Output is correct |
49 | Correct | 279 ms | 19004 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 6492 KB | Output is correct |
2 | Correct | 1 ms | 6588 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 6488 KB | Output is correct |
9 | Correct | 2 ms | 6492 KB | Output is correct |
10 | Correct | 1 ms | 440 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 360 KB | Output is correct |
15 | Correct | 1 ms | 6492 KB | Output is correct |
16 | Correct | 1 ms | 6492 KB | Output is correct |
17 | Correct | 2 ms | 6492 KB | Output is correct |
18 | Correct | 1 ms | 344 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 348 KB | Output is correct |
22 | Correct | 1 ms | 6492 KB | Output is correct |
23 | Correct | 1 ms | 6492 KB | Output is correct |
24 | Correct | 1 ms | 348 KB | Output is correct |
25 | Correct | 1 ms | 348 KB | Output is correct |
26 | Correct | 1 ms | 348 KB | Output is correct |
27 | Correct | 1 ms | 348 KB | Output is correct |
28 | Correct | 1 ms | 6492 KB | Output is correct |
29 | Correct | 2 ms | 6492 KB | Output is correct |
30 | Correct | 2 ms | 6492 KB | Output is correct |
31 | Correct | 1 ms | 344 KB | Output is correct |
32 | Correct | 1 ms | 344 KB | Output is correct |
33 | Correct | 1 ms | 348 KB | Output is correct |
34 | Correct | 1 ms | 348 KB | Output is correct |
35 | Correct | 265 ms | 17920 KB | Output is correct |
36 | Correct | 276 ms | 18660 KB | Output is correct |
37 | Correct | 271 ms | 18876 KB | Output is correct |
38 | Correct | 264 ms | 18764 KB | Output is correct |
39 | Correct | 264 ms | 18028 KB | Output is correct |
40 | Correct | 264 ms | 18768 KB | Output is correct |
41 | Correct | 264 ms | 18840 KB | Output is correct |
42 | Correct | 260 ms | 18024 KB | Output is correct |
43 | Correct | 265 ms | 18000 KB | Output is correct |
44 | Correct | 268 ms | 17964 KB | Output is correct |
45 | Correct | 263 ms | 18000 KB | Output is correct |
46 | Correct | 262 ms | 18004 KB | Output is correct |
47 | Correct | 293 ms | 18004 KB | Output is correct |
48 | Correct | 266 ms | 18880 KB | Output is correct |
49 | Correct | 279 ms | 19004 KB | Output is correct |
50 | Correct | 273 ms | 20892 KB | Output is correct |
51 | Correct | 275 ms | 20816 KB | Output is correct |
52 | Correct | 272 ms | 20772 KB | Output is correct |
53 | Correct | 288 ms | 20800 KB | Output is correct |
54 | Correct | 304 ms | 21052 KB | Output is correct |
55 | Correct | 279 ms | 20728 KB | Output is correct |
56 | Correct | 299 ms | 20716 KB | Output is correct |
57 | Correct | 268 ms | 19792 KB | Output is correct |
58 | Correct | 268 ms | 20916 KB | Output is correct |
59 | Correct | 272 ms | 20716 KB | Output is correct |
60 | Correct | 266 ms | 19924 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 6492 KB | Output is correct |
2 | Correct | 1 ms | 6588 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 6488 KB | Output is correct |
9 | Correct | 2 ms | 6492 KB | Output is correct |
10 | Correct | 1 ms | 440 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 360 KB | Output is correct |
15 | Correct | 1 ms | 6492 KB | Output is correct |
16 | Correct | 1 ms | 6492 KB | Output is correct |
17 | Correct | 2 ms | 6492 KB | Output is correct |
18 | Correct | 1 ms | 344 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 348 KB | Output is correct |
22 | Correct | 1 ms | 6492 KB | Output is correct |
23 | Correct | 1 ms | 6492 KB | Output is correct |
24 | Correct | 1 ms | 348 KB | Output is correct |
25 | Correct | 1 ms | 348 KB | Output is correct |
26 | Correct | 1 ms | 348 KB | Output is correct |
27 | Correct | 1 ms | 348 KB | Output is correct |
28 | Correct | 1 ms | 6492 KB | Output is correct |
29 | Correct | 2 ms | 6492 KB | Output is correct |
30 | Correct | 2 ms | 6492 KB | Output is correct |
31 | Correct | 1 ms | 344 KB | Output is correct |
32 | Correct | 1 ms | 344 KB | Output is correct |
33 | Correct | 1 ms | 348 KB | Output is correct |
34 | Correct | 1 ms | 348 KB | Output is correct |
35 | Correct | 265 ms | 17920 KB | Output is correct |
36 | Correct | 276 ms | 18660 KB | Output is correct |
37 | Correct | 271 ms | 18876 KB | Output is correct |
38 | Correct | 264 ms | 18764 KB | Output is correct |
39 | Correct | 264 ms | 18028 KB | Output is correct |
40 | Correct | 264 ms | 18768 KB | Output is correct |
41 | Correct | 264 ms | 18840 KB | Output is correct |
42 | Correct | 260 ms | 18024 KB | Output is correct |
43 | Correct | 265 ms | 18000 KB | Output is correct |
44 | Correct | 268 ms | 17964 KB | Output is correct |
45 | Correct | 263 ms | 18000 KB | Output is correct |
46 | Correct | 262 ms | 18004 KB | Output is correct |
47 | Correct | 293 ms | 18004 KB | Output is correct |
48 | Correct | 266 ms | 18880 KB | Output is correct |
49 | Correct | 279 ms | 19004 KB | Output is correct |
50 | Correct | 273 ms | 20892 KB | Output is correct |
51 | Correct | 275 ms | 20816 KB | Output is correct |
52 | Correct | 272 ms | 20772 KB | Output is correct |
53 | Correct | 288 ms | 20800 KB | Output is correct |
54 | Correct | 304 ms | 21052 KB | Output is correct |
55 | Correct | 279 ms | 20728 KB | Output is correct |
56 | Correct | 299 ms | 20716 KB | Output is correct |
57 | Correct | 268 ms | 19792 KB | Output is correct |
58 | Correct | 268 ms | 20916 KB | Output is correct |
59 | Correct | 272 ms | 20716 KB | Output is correct |
60 | Correct | 266 ms | 19924 KB | Output is correct |
61 | Correct | 206 ms | 12020 KB | Output is correct |
62 | Correct | 208 ms | 12908 KB | Output is correct |
63 | Correct | 205 ms | 12112 KB | Output is correct |
64 | Correct | 209 ms | 12908 KB | Output is correct |
65 | Correct | 247 ms | 17544 KB | Output is correct |
66 | Correct | 230 ms | 17328 KB | Output is correct |
67 | Correct | 268 ms | 20660 KB | Output is correct |
68 | Correct | 211 ms | 12908 KB | Output is correct |
69 | Correct | 210 ms | 12092 KB | Output is correct |
70 | Correct | 207 ms | 12912 KB | Output is correct |
71 | Correct | 205 ms | 11988 KB | Output is correct |