답안 #851558

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
851558 2023-09-20T06:42:18 Z khanhphucscratch Binaria (CCO23_day1problem1) C++14
25 / 25
69 ms 34640 KB
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[1000001], fact[1000001], inv[1000001], color[1000001];
const int mod = 1e6+3;
int power(int a, int b)
{
    if(b == 0) return 1;
    int ans = power(a, b/2);
    ans = (ans * ans)%mod;
    if(b%2 == 1) ans = (ans * a)%mod;
    return ans;
}
int C(int k, int n)
{
    if(k > n || k < 0) return 0;
    return (fact[n] * ((inv[k] * inv[n-k])%mod))%mod;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin>>n>>k;
    fact[0] = inv[0] = 1;
    for(int i = 1; i <= n; i++) fact[i] = (fact[i-1] * i)%mod;
    inv[n] = power(fact[n], mod-2);
    for(int i = n-1; i >= 1; i--) inv[i] = (inv[i+1] * (i+1))%mod;
    for(int i = 1; i <= n-k+1; i++) cin>>a[i];
    for(int i = 1; i <= n; i++) color[i] = 2;
    for(int i = n-k; i >= 1; i--){
        if(abs(a[i] - a[i+1]) > 1){cout<<0; return 0;}
        if(a[i] == a[i+1]) color[i] = color[i+k];
        else if(a[i] > a[i+1]){
            if(color[i+k] == 1){cout<<0; return 0;}
            color[i] = 1;
        }
        else{
            if(color[i+k] == 0){cout<<0; return 0;}
            color[i] = 0;
        }
    }
    /*for(int i = 1; i <= n; i++) cout<<color[i]<<" ";
    cout<<'\n';*/
    int re = 0;
    for(int i = 1; i <= k; i++){a[1] -= (color[i] == 1); re += (color[i] == 2);}
    cout<<C(a[1], re);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6488 KB Output is correct
3 Correct 1 ms 6488 KB Output is correct
4 Correct 1 ms 6488 KB Output is correct
5 Correct 1 ms 6488 KB Output is correct
6 Correct 1 ms 6488 KB Output is correct
7 Correct 1 ms 6488 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6488 KB Output is correct
10 Correct 1 ms 6688 KB Output is correct
11 Correct 1 ms 6488 KB Output is correct
12 Correct 1 ms 6488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6488 KB Output is correct
3 Correct 1 ms 6488 KB Output is correct
4 Correct 1 ms 6488 KB Output is correct
5 Correct 1 ms 6488 KB Output is correct
6 Correct 1 ms 6488 KB Output is correct
7 Correct 1 ms 6488 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6488 KB Output is correct
10 Correct 1 ms 6688 KB Output is correct
11 Correct 1 ms 6488 KB Output is correct
12 Correct 1 ms 6488 KB Output is correct
13 Correct 1 ms 6488 KB Output is correct
14 Correct 1 ms 6488 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 1 ms 6488 KB Output is correct
17 Correct 2 ms 6488 KB Output is correct
18 Correct 1 ms 6488 KB Output is correct
19 Correct 1 ms 6488 KB Output is correct
20 Correct 1 ms 6488 KB Output is correct
21 Correct 1 ms 6488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6488 KB Output is correct
3 Correct 1 ms 6488 KB Output is correct
4 Correct 1 ms 6488 KB Output is correct
5 Correct 1 ms 6488 KB Output is correct
6 Correct 1 ms 6488 KB Output is correct
7 Correct 1 ms 6488 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6488 KB Output is correct
10 Correct 1 ms 6688 KB Output is correct
11 Correct 1 ms 6488 KB Output is correct
12 Correct 1 ms 6488 KB Output is correct
13 Correct 1 ms 6488 KB Output is correct
14 Correct 1 ms 6488 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 1 ms 6488 KB Output is correct
17 Correct 2 ms 6488 KB Output is correct
18 Correct 1 ms 6488 KB Output is correct
19 Correct 1 ms 6488 KB Output is correct
20 Correct 1 ms 6488 KB Output is correct
21 Correct 1 ms 6488 KB Output is correct
22 Correct 1 ms 6488 KB Output is correct
23 Correct 1 ms 6488 KB Output is correct
24 Correct 1 ms 6492 KB Output is correct
25 Correct 1 ms 6488 KB Output is correct
26 Correct 1 ms 6492 KB Output is correct
27 Correct 1 ms 6488 KB Output is correct
28 Correct 1 ms 6488 KB Output is correct
29 Correct 1 ms 6488 KB Output is correct
30 Correct 1 ms 6488 KB Output is correct
31 Correct 1 ms 6488 KB Output is correct
32 Correct 1 ms 6616 KB Output is correct
33 Correct 1 ms 6488 KB Output is correct
34 Correct 2 ms 6488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6488 KB Output is correct
3 Correct 1 ms 6488 KB Output is correct
4 Correct 1 ms 6488 KB Output is correct
5 Correct 1 ms 6488 KB Output is correct
6 Correct 1 ms 6488 KB Output is correct
7 Correct 1 ms 6488 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6488 KB Output is correct
10 Correct 1 ms 6688 KB Output is correct
11 Correct 1 ms 6488 KB Output is correct
12 Correct 1 ms 6488 KB Output is correct
13 Correct 1 ms 6488 KB Output is correct
14 Correct 1 ms 6488 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 1 ms 6488 KB Output is correct
17 Correct 2 ms 6488 KB Output is correct
18 Correct 1 ms 6488 KB Output is correct
19 Correct 1 ms 6488 KB Output is correct
20 Correct 1 ms 6488 KB Output is correct
21 Correct 1 ms 6488 KB Output is correct
22 Correct 1 ms 6488 KB Output is correct
23 Correct 1 ms 6488 KB Output is correct
24 Correct 1 ms 6492 KB Output is correct
25 Correct 1 ms 6488 KB Output is correct
26 Correct 1 ms 6492 KB Output is correct
27 Correct 1 ms 6488 KB Output is correct
28 Correct 1 ms 6488 KB Output is correct
29 Correct 1 ms 6488 KB Output is correct
30 Correct 1 ms 6488 KB Output is correct
31 Correct 1 ms 6488 KB Output is correct
32 Correct 1 ms 6616 KB Output is correct
33 Correct 1 ms 6488 KB Output is correct
34 Correct 2 ms 6488 KB Output is correct
35 Correct 57 ms 32848 KB Output is correct
36 Correct 58 ms 33104 KB Output is correct
37 Correct 59 ms 33360 KB Output is correct
38 Correct 58 ms 33488 KB Output is correct
39 Correct 52 ms 32848 KB Output is correct
40 Correct 57 ms 33360 KB Output is correct
41 Correct 58 ms 33360 KB Output is correct
42 Correct 56 ms 32856 KB Output is correct
43 Correct 53 ms 33000 KB Output is correct
44 Correct 62 ms 33104 KB Output is correct
45 Correct 53 ms 32844 KB Output is correct
46 Correct 60 ms 32848 KB Output is correct
47 Correct 57 ms 32848 KB Output is correct
48 Correct 59 ms 33356 KB Output is correct
49 Correct 58 ms 33532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6488 KB Output is correct
3 Correct 1 ms 6488 KB Output is correct
4 Correct 1 ms 6488 KB Output is correct
5 Correct 1 ms 6488 KB Output is correct
6 Correct 1 ms 6488 KB Output is correct
7 Correct 1 ms 6488 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6488 KB Output is correct
10 Correct 1 ms 6688 KB Output is correct
11 Correct 1 ms 6488 KB Output is correct
12 Correct 1 ms 6488 KB Output is correct
13 Correct 1 ms 6488 KB Output is correct
14 Correct 1 ms 6488 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 1 ms 6488 KB Output is correct
17 Correct 2 ms 6488 KB Output is correct
18 Correct 1 ms 6488 KB Output is correct
19 Correct 1 ms 6488 KB Output is correct
20 Correct 1 ms 6488 KB Output is correct
21 Correct 1 ms 6488 KB Output is correct
22 Correct 1 ms 6488 KB Output is correct
23 Correct 1 ms 6488 KB Output is correct
24 Correct 1 ms 6492 KB Output is correct
25 Correct 1 ms 6488 KB Output is correct
26 Correct 1 ms 6492 KB Output is correct
27 Correct 1 ms 6488 KB Output is correct
28 Correct 1 ms 6488 KB Output is correct
29 Correct 1 ms 6488 KB Output is correct
30 Correct 1 ms 6488 KB Output is correct
31 Correct 1 ms 6488 KB Output is correct
32 Correct 1 ms 6616 KB Output is correct
33 Correct 1 ms 6488 KB Output is correct
34 Correct 2 ms 6488 KB Output is correct
35 Correct 57 ms 32848 KB Output is correct
36 Correct 58 ms 33104 KB Output is correct
37 Correct 59 ms 33360 KB Output is correct
38 Correct 58 ms 33488 KB Output is correct
39 Correct 52 ms 32848 KB Output is correct
40 Correct 57 ms 33360 KB Output is correct
41 Correct 58 ms 33360 KB Output is correct
42 Correct 56 ms 32856 KB Output is correct
43 Correct 53 ms 33000 KB Output is correct
44 Correct 62 ms 33104 KB Output is correct
45 Correct 53 ms 32844 KB Output is correct
46 Correct 60 ms 32848 KB Output is correct
47 Correct 57 ms 32848 KB Output is correct
48 Correct 59 ms 33356 KB Output is correct
49 Correct 58 ms 33532 KB Output is correct
50 Correct 68 ms 34392 KB Output is correct
51 Correct 68 ms 34384 KB Output is correct
52 Correct 68 ms 34516 KB Output is correct
53 Correct 68 ms 34508 KB Output is correct
54 Correct 68 ms 34384 KB Output is correct
55 Correct 68 ms 34384 KB Output is correct
56 Correct 69 ms 34384 KB Output is correct
57 Correct 65 ms 34384 KB Output is correct
58 Correct 68 ms 34384 KB Output is correct
59 Correct 67 ms 34640 KB Output is correct
60 Correct 65 ms 33876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6488 KB Output is correct
3 Correct 1 ms 6488 KB Output is correct
4 Correct 1 ms 6488 KB Output is correct
5 Correct 1 ms 6488 KB Output is correct
6 Correct 1 ms 6488 KB Output is correct
7 Correct 1 ms 6488 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6488 KB Output is correct
10 Correct 1 ms 6688 KB Output is correct
11 Correct 1 ms 6488 KB Output is correct
12 Correct 1 ms 6488 KB Output is correct
13 Correct 1 ms 6488 KB Output is correct
14 Correct 1 ms 6488 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 1 ms 6488 KB Output is correct
17 Correct 2 ms 6488 KB Output is correct
18 Correct 1 ms 6488 KB Output is correct
19 Correct 1 ms 6488 KB Output is correct
20 Correct 1 ms 6488 KB Output is correct
21 Correct 1 ms 6488 KB Output is correct
22 Correct 1 ms 6488 KB Output is correct
23 Correct 1 ms 6488 KB Output is correct
24 Correct 1 ms 6492 KB Output is correct
25 Correct 1 ms 6488 KB Output is correct
26 Correct 1 ms 6492 KB Output is correct
27 Correct 1 ms 6488 KB Output is correct
28 Correct 1 ms 6488 KB Output is correct
29 Correct 1 ms 6488 KB Output is correct
30 Correct 1 ms 6488 KB Output is correct
31 Correct 1 ms 6488 KB Output is correct
32 Correct 1 ms 6616 KB Output is correct
33 Correct 1 ms 6488 KB Output is correct
34 Correct 2 ms 6488 KB Output is correct
35 Correct 57 ms 32848 KB Output is correct
36 Correct 58 ms 33104 KB Output is correct
37 Correct 59 ms 33360 KB Output is correct
38 Correct 58 ms 33488 KB Output is correct
39 Correct 52 ms 32848 KB Output is correct
40 Correct 57 ms 33360 KB Output is correct
41 Correct 58 ms 33360 KB Output is correct
42 Correct 56 ms 32856 KB Output is correct
43 Correct 53 ms 33000 KB Output is correct
44 Correct 62 ms 33104 KB Output is correct
45 Correct 53 ms 32844 KB Output is correct
46 Correct 60 ms 32848 KB Output is correct
47 Correct 57 ms 32848 KB Output is correct
48 Correct 59 ms 33356 KB Output is correct
49 Correct 58 ms 33532 KB Output is correct
50 Correct 68 ms 34392 KB Output is correct
51 Correct 68 ms 34384 KB Output is correct
52 Correct 68 ms 34516 KB Output is correct
53 Correct 68 ms 34508 KB Output is correct
54 Correct 68 ms 34384 KB Output is correct
55 Correct 68 ms 34384 KB Output is correct
56 Correct 69 ms 34384 KB Output is correct
57 Correct 65 ms 34384 KB Output is correct
58 Correct 68 ms 34384 KB Output is correct
59 Correct 67 ms 34640 KB Output is correct
60 Correct 65 ms 33876 KB Output is correct
61 Correct 17 ms 25168 KB Output is correct
62 Correct 18 ms 25180 KB Output is correct
63 Correct 17 ms 25176 KB Output is correct
64 Correct 17 ms 25176 KB Output is correct
65 Correct 48 ms 31212 KB Output is correct
66 Correct 39 ms 28748 KB Output is correct
67 Correct 66 ms 34300 KB Output is correct
68 Correct 22 ms 25680 KB Output is correct
69 Correct 17 ms 25176 KB Output is correct
70 Correct 17 ms 25180 KB Output is correct
71 Correct 17 ms 25176 KB Output is correct