Submission #1038883

# Submission time Handle Problem Language Result Execution time Memory
1038883 2024-07-30T08:39:47 Z vjudge1 Binaria (CCO23_day1problem1) C++17
25 / 25
138 ms 21080 KB
//ᗜˬᗜ
#include<bits/stdc++.h>
#define int long long
#define vi vector <int>
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define pb emplace_back
#define fu(i, a, b) for(int i = (a); i < (b); i++)
#define fub(i, a, b) for(int i = (a); i <= (b); i++)
#define pii pair<int, int>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
const int lim = 1e18;
const int N = 1e6 + 3;
const int M = 1e9 + 7;
int n, k, res;
int a[N], mp[N];
int expo(int a, int b){
    if(b == 0)return 1;
    if(b%2 == 0)return expo((a*a)%N, b/2)%N;
    return (a*expo((a*a)%N, b/2))%N;
}
int bico(int n, int k){
    if(k > n or n < 0 or k < 0)return 0;
    int res = 1;
    fub(i, k+1, n)res = (res*i)%N;
    fub(i, 1, n-k)res = (res*expo(i, N-2))%N;
    return res;

}
signed main(){
    fastio;
    cin >> n >> k;
    fub(i, 1, n-k+1)cin >> a[i];
    memset(mp, -1, sizeof(mp));
    fub(i, 2, n-k+1){
        if(abs(a[i] - a[i-1]) > 1){
            cout << 0;
            return 0;
        }
    }
    fub(i, 2, n-k+1){
        if(a[i] - a[i-1] == 1){
            mp[i+k-1] = 1; mp[i-1] = 0;
        }
        else if(a[i] - a[i-1] == -1){
            mp[i+k-1] = 0; mp[i-1] = 1;
        }
        else mp[i+k-1] = mp[i-1];
    }
    for(int i = n-k; i >= 1; i--)if(a[i] == a[i+1])mp[i] = mp[i+k];
    fub(i, 1, k){
        res += (mp[i] == -1);
        a[1] -= (mp[i] == 1);
    }
    cout << bico(res, a[1]);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8796 KB Output is correct
2 Correct 1 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Correct 1 ms 8796 KB Output is correct
5 Correct 1 ms 8796 KB Output is correct
6 Correct 1 ms 8796 KB Output is correct
7 Correct 1 ms 8796 KB Output is correct
8 Correct 1 ms 8796 KB Output is correct
9 Correct 1 ms 8796 KB Output is correct
10 Correct 1 ms 8796 KB Output is correct
11 Correct 1 ms 8796 KB Output is correct
12 Correct 1 ms 8844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8796 KB Output is correct
2 Correct 1 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Correct 1 ms 8796 KB Output is correct
5 Correct 1 ms 8796 KB Output is correct
6 Correct 1 ms 8796 KB Output is correct
7 Correct 1 ms 8796 KB Output is correct
8 Correct 1 ms 8796 KB Output is correct
9 Correct 1 ms 8796 KB Output is correct
10 Correct 1 ms 8796 KB Output is correct
11 Correct 1 ms 8796 KB Output is correct
12 Correct 1 ms 8844 KB Output is correct
13 Correct 1 ms 8796 KB Output is correct
14 Correct 1 ms 8796 KB Output is correct
15 Correct 1 ms 8728 KB Output is correct
16 Correct 1 ms 8796 KB Output is correct
17 Correct 1 ms 8796 KB Output is correct
18 Correct 1 ms 8796 KB Output is correct
19 Correct 1 ms 8796 KB Output is correct
20 Correct 1 ms 8796 KB Output is correct
21 Correct 1 ms 8796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8796 KB Output is correct
2 Correct 1 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Correct 1 ms 8796 KB Output is correct
5 Correct 1 ms 8796 KB Output is correct
6 Correct 1 ms 8796 KB Output is correct
7 Correct 1 ms 8796 KB Output is correct
8 Correct 1 ms 8796 KB Output is correct
9 Correct 1 ms 8796 KB Output is correct
10 Correct 1 ms 8796 KB Output is correct
11 Correct 1 ms 8796 KB Output is correct
12 Correct 1 ms 8844 KB Output is correct
13 Correct 1 ms 8796 KB Output is correct
14 Correct 1 ms 8796 KB Output is correct
15 Correct 1 ms 8728 KB Output is correct
16 Correct 1 ms 8796 KB Output is correct
17 Correct 1 ms 8796 KB Output is correct
18 Correct 1 ms 8796 KB Output is correct
19 Correct 1 ms 8796 KB Output is correct
20 Correct 1 ms 8796 KB Output is correct
21 Correct 1 ms 8796 KB Output is correct
22 Correct 1 ms 8796 KB Output is correct
23 Correct 2 ms 8796 KB Output is correct
24 Correct 1 ms 8796 KB Output is correct
25 Correct 1 ms 8656 KB Output is correct
26 Correct 1 ms 8796 KB Output is correct
27 Correct 1 ms 8652 KB Output is correct
28 Correct 1 ms 8796 KB Output is correct
29 Correct 1 ms 8796 KB Output is correct
30 Correct 1 ms 8796 KB Output is correct
31 Correct 1 ms 8796 KB Output is correct
32 Correct 1 ms 8796 KB Output is correct
33 Correct 1 ms 8796 KB Output is correct
34 Correct 1 ms 8796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8796 KB Output is correct
2 Correct 1 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Correct 1 ms 8796 KB Output is correct
5 Correct 1 ms 8796 KB Output is correct
6 Correct 1 ms 8796 KB Output is correct
7 Correct 1 ms 8796 KB Output is correct
8 Correct 1 ms 8796 KB Output is correct
9 Correct 1 ms 8796 KB Output is correct
10 Correct 1 ms 8796 KB Output is correct
11 Correct 1 ms 8796 KB Output is correct
12 Correct 1 ms 8844 KB Output is correct
13 Correct 1 ms 8796 KB Output is correct
14 Correct 1 ms 8796 KB Output is correct
15 Correct 1 ms 8728 KB Output is correct
16 Correct 1 ms 8796 KB Output is correct
17 Correct 1 ms 8796 KB Output is correct
18 Correct 1 ms 8796 KB Output is correct
19 Correct 1 ms 8796 KB Output is correct
20 Correct 1 ms 8796 KB Output is correct
21 Correct 1 ms 8796 KB Output is correct
22 Correct 1 ms 8796 KB Output is correct
23 Correct 2 ms 8796 KB Output is correct
24 Correct 1 ms 8796 KB Output is correct
25 Correct 1 ms 8656 KB Output is correct
26 Correct 1 ms 8796 KB Output is correct
27 Correct 1 ms 8652 KB Output is correct
28 Correct 1 ms 8796 KB Output is correct
29 Correct 1 ms 8796 KB Output is correct
30 Correct 1 ms 8796 KB Output is correct
31 Correct 1 ms 8796 KB Output is correct
32 Correct 1 ms 8796 KB Output is correct
33 Correct 1 ms 8796 KB Output is correct
34 Correct 1 ms 8796 KB Output is correct
35 Correct 35 ms 18000 KB Output is correct
36 Correct 39 ms 18516 KB Output is correct
37 Correct 41 ms 18768 KB Output is correct
38 Correct 41 ms 19008 KB Output is correct
39 Correct 35 ms 18004 KB Output is correct
40 Correct 38 ms 18772 KB Output is correct
41 Correct 38 ms 19012 KB Output is correct
42 Correct 36 ms 18000 KB Output is correct
43 Correct 35 ms 17864 KB Output is correct
44 Correct 34 ms 18000 KB Output is correct
45 Correct 33 ms 17996 KB Output is correct
46 Correct 32 ms 17864 KB Output is correct
47 Correct 35 ms 18004 KB Output is correct
48 Correct 39 ms 18772 KB Output is correct
49 Correct 38 ms 18784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8796 KB Output is correct
2 Correct 1 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Correct 1 ms 8796 KB Output is correct
5 Correct 1 ms 8796 KB Output is correct
6 Correct 1 ms 8796 KB Output is correct
7 Correct 1 ms 8796 KB Output is correct
8 Correct 1 ms 8796 KB Output is correct
9 Correct 1 ms 8796 KB Output is correct
10 Correct 1 ms 8796 KB Output is correct
11 Correct 1 ms 8796 KB Output is correct
12 Correct 1 ms 8844 KB Output is correct
13 Correct 1 ms 8796 KB Output is correct
14 Correct 1 ms 8796 KB Output is correct
15 Correct 1 ms 8728 KB Output is correct
16 Correct 1 ms 8796 KB Output is correct
17 Correct 1 ms 8796 KB Output is correct
18 Correct 1 ms 8796 KB Output is correct
19 Correct 1 ms 8796 KB Output is correct
20 Correct 1 ms 8796 KB Output is correct
21 Correct 1 ms 8796 KB Output is correct
22 Correct 1 ms 8796 KB Output is correct
23 Correct 2 ms 8796 KB Output is correct
24 Correct 1 ms 8796 KB Output is correct
25 Correct 1 ms 8656 KB Output is correct
26 Correct 1 ms 8796 KB Output is correct
27 Correct 1 ms 8652 KB Output is correct
28 Correct 1 ms 8796 KB Output is correct
29 Correct 1 ms 8796 KB Output is correct
30 Correct 1 ms 8796 KB Output is correct
31 Correct 1 ms 8796 KB Output is correct
32 Correct 1 ms 8796 KB Output is correct
33 Correct 1 ms 8796 KB Output is correct
34 Correct 1 ms 8796 KB Output is correct
35 Correct 35 ms 18000 KB Output is correct
36 Correct 39 ms 18516 KB Output is correct
37 Correct 41 ms 18768 KB Output is correct
38 Correct 41 ms 19008 KB Output is correct
39 Correct 35 ms 18004 KB Output is correct
40 Correct 38 ms 18772 KB Output is correct
41 Correct 38 ms 19012 KB Output is correct
42 Correct 36 ms 18000 KB Output is correct
43 Correct 35 ms 17864 KB Output is correct
44 Correct 34 ms 18000 KB Output is correct
45 Correct 33 ms 17996 KB Output is correct
46 Correct 32 ms 17864 KB Output is correct
47 Correct 35 ms 18004 KB Output is correct
48 Correct 39 ms 18772 KB Output is correct
49 Correct 38 ms 18784 KB Output is correct
50 Correct 47 ms 20816 KB Output is correct
51 Correct 47 ms 20816 KB Output is correct
52 Correct 48 ms 20816 KB Output is correct
53 Correct 52 ms 20796 KB Output is correct
54 Correct 47 ms 20800 KB Output is correct
55 Correct 47 ms 20808 KB Output is correct
56 Correct 48 ms 20820 KB Output is correct
57 Correct 44 ms 19900 KB Output is correct
58 Correct 48 ms 20920 KB Output is correct
59 Correct 66 ms 21080 KB Output is correct
60 Correct 43 ms 19804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8796 KB Output is correct
2 Correct 1 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Correct 1 ms 8796 KB Output is correct
5 Correct 1 ms 8796 KB Output is correct
6 Correct 1 ms 8796 KB Output is correct
7 Correct 1 ms 8796 KB Output is correct
8 Correct 1 ms 8796 KB Output is correct
9 Correct 1 ms 8796 KB Output is correct
10 Correct 1 ms 8796 KB Output is correct
11 Correct 1 ms 8796 KB Output is correct
12 Correct 1 ms 8844 KB Output is correct
13 Correct 1 ms 8796 KB Output is correct
14 Correct 1 ms 8796 KB Output is correct
15 Correct 1 ms 8728 KB Output is correct
16 Correct 1 ms 8796 KB Output is correct
17 Correct 1 ms 8796 KB Output is correct
18 Correct 1 ms 8796 KB Output is correct
19 Correct 1 ms 8796 KB Output is correct
20 Correct 1 ms 8796 KB Output is correct
21 Correct 1 ms 8796 KB Output is correct
22 Correct 1 ms 8796 KB Output is correct
23 Correct 2 ms 8796 KB Output is correct
24 Correct 1 ms 8796 KB Output is correct
25 Correct 1 ms 8656 KB Output is correct
26 Correct 1 ms 8796 KB Output is correct
27 Correct 1 ms 8652 KB Output is correct
28 Correct 1 ms 8796 KB Output is correct
29 Correct 1 ms 8796 KB Output is correct
30 Correct 1 ms 8796 KB Output is correct
31 Correct 1 ms 8796 KB Output is correct
32 Correct 1 ms 8796 KB Output is correct
33 Correct 1 ms 8796 KB Output is correct
34 Correct 1 ms 8796 KB Output is correct
35 Correct 35 ms 18000 KB Output is correct
36 Correct 39 ms 18516 KB Output is correct
37 Correct 41 ms 18768 KB Output is correct
38 Correct 41 ms 19008 KB Output is correct
39 Correct 35 ms 18004 KB Output is correct
40 Correct 38 ms 18772 KB Output is correct
41 Correct 38 ms 19012 KB Output is correct
42 Correct 36 ms 18000 KB Output is correct
43 Correct 35 ms 17864 KB Output is correct
44 Correct 34 ms 18000 KB Output is correct
45 Correct 33 ms 17996 KB Output is correct
46 Correct 32 ms 17864 KB Output is correct
47 Correct 35 ms 18004 KB Output is correct
48 Correct 39 ms 18772 KB Output is correct
49 Correct 38 ms 18784 KB Output is correct
50 Correct 47 ms 20816 KB Output is correct
51 Correct 47 ms 20816 KB Output is correct
52 Correct 48 ms 20816 KB Output is correct
53 Correct 52 ms 20796 KB Output is correct
54 Correct 47 ms 20800 KB Output is correct
55 Correct 47 ms 20808 KB Output is correct
56 Correct 48 ms 20820 KB Output is correct
57 Correct 44 ms 19900 KB Output is correct
58 Correct 48 ms 20920 KB Output is correct
59 Correct 66 ms 21080 KB Output is correct
60 Correct 43 ms 19804 KB Output is correct
61 Correct 69 ms 8796 KB Output is correct
62 Correct 82 ms 8828 KB Output is correct
63 Correct 18 ms 8792 KB Output is correct
64 Correct 61 ms 8660 KB Output is correct
65 Correct 54 ms 16468 KB Output is correct
66 Correct 65 ms 15192 KB Output is correct
67 Correct 56 ms 20304 KB Output is correct
68 Correct 129 ms 11152 KB Output is correct
69 Correct 2 ms 8796 KB Output is correct
70 Correct 138 ms 8844 KB Output is correct
71 Correct 68 ms 8792 KB Output is correct