# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1027280 | 2024-07-19T03:11:28 Z | khanhtb | Binaria (CCO23_day1problem1) | C++14 | 69 ms | 31648 KB |
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define ld long double #define pb push_back #define pf push_front #define vi vector<ll> #define vii vector<vi> #define pll pair<ll, ll> #define vpll vector<pll> #define all(a) a.begin(), a.end() #define fi first #define se second using namespace std; const ll mod = 1e6 + 3; const ll inf = 2e18; const ll blocksz = 320; const ll N = 1e6 + 1; ll n,fac[N],invfac[N]; ll bipow(ll a, ll b){ ll ans = 1; while(b){ if(b&1) ans = ans*a%mod; a = a*a%mod; b>>=1; } return ans; } void precalc(){ fac[0] = 1; for(ll i = 1; i < N; i++) fac[i] = fac[i-1]*i%mod; invfac[N-1] = bipow(fac[N-1],mod-2); for(ll i = N-2; i >= 0; i--) invfac[i] = invfac[i+1]*(i+1)%mod; } ll C(ll k, ll n){ if(k > n || k < 0) return 0; return ((fac[n]*invfac[k])%mod)*invfac[n-k]%mod; } ll k,a[N]; ll d[N]; void solve(){ cin >> n >> k; fill(a,a+n+1,-1); for(ll i = 1; i <= n-k+1; i++) cin >> d[i]; for(ll i = n-k; i >= 1; i--){ if(abs(d[i]-d[i+1]) > 1){ cout << 0; return; } if(d[i] > d[i+1]){ if(a[i+k] == 1){ cout << 0; return; } a[i] = 1; } else if(d[i] < d[i+1]){ if(a[i+k] == 0){ cout << 0; return; } a[i] = 0; } else if(d[i] == d[i+1]) a[i] = a[i+k]; } precalc(); ll cnt = 0; ll n1 = d[1]; for(ll i = 1; i <= k; i++){ if(a[i] == -1) cnt++; if(a[i] == 1) n1--; } cout << C(n1,cnt); } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("test.inp", "r")){ freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } ll T = 1; // cin >> T; for (ll i = 1; i <= T; i++){ solve(); cout << '\n'; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 19032 KB | Output is correct |
2 | Correct | 11 ms | 19036 KB | Output is correct |
3 | Correct | 11 ms | 19164 KB | Output is correct |
4 | Correct | 11 ms | 19036 KB | Output is correct |
5 | Correct | 11 ms | 19032 KB | Output is correct |
6 | Correct | 11 ms | 19036 KB | Output is correct |
7 | Correct | 11 ms | 19032 KB | Output is correct |
8 | Correct | 11 ms | 19036 KB | Output is correct |
9 | Correct | 11 ms | 19164 KB | Output is correct |
10 | Correct | 11 ms | 19108 KB | Output is correct |
11 | Correct | 11 ms | 19180 KB | Output is correct |
12 | Correct | 12 ms | 19032 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 19032 KB | Output is correct |
2 | Correct | 11 ms | 19036 KB | Output is correct |
3 | Correct | 11 ms | 19164 KB | Output is correct |
4 | Correct | 11 ms | 19036 KB | Output is correct |
5 | Correct | 11 ms | 19032 KB | Output is correct |
6 | Correct | 11 ms | 19036 KB | Output is correct |
7 | Correct | 11 ms | 19032 KB | Output is correct |
8 | Correct | 11 ms | 19036 KB | Output is correct |
9 | Correct | 11 ms | 19164 KB | Output is correct |
10 | Correct | 11 ms | 19108 KB | Output is correct |
11 | Correct | 11 ms | 19180 KB | Output is correct |
12 | Correct | 12 ms | 19032 KB | Output is correct |
13 | Correct | 13 ms | 19292 KB | Output is correct |
14 | Correct | 11 ms | 19036 KB | Output is correct |
15 | Correct | 11 ms | 19036 KB | Output is correct |
16 | Correct | 12 ms | 19036 KB | Output is correct |
17 | Correct | 12 ms | 19032 KB | Output is correct |
18 | Correct | 11 ms | 19276 KB | Output is correct |
19 | Correct | 11 ms | 19036 KB | Output is correct |
20 | Correct | 11 ms | 19036 KB | Output is correct |
21 | Correct | 11 ms | 19268 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 19032 KB | Output is correct |
2 | Correct | 11 ms | 19036 KB | Output is correct |
3 | Correct | 11 ms | 19164 KB | Output is correct |
4 | Correct | 11 ms | 19036 KB | Output is correct |
5 | Correct | 11 ms | 19032 KB | Output is correct |
6 | Correct | 11 ms | 19036 KB | Output is correct |
7 | Correct | 11 ms | 19032 KB | Output is correct |
8 | Correct | 11 ms | 19036 KB | Output is correct |
9 | Correct | 11 ms | 19164 KB | Output is correct |
10 | Correct | 11 ms | 19108 KB | Output is correct |
11 | Correct | 11 ms | 19180 KB | Output is correct |
12 | Correct | 12 ms | 19032 KB | Output is correct |
13 | Correct | 13 ms | 19292 KB | Output is correct |
14 | Correct | 11 ms | 19036 KB | Output is correct |
15 | Correct | 11 ms | 19036 KB | Output is correct |
16 | Correct | 12 ms | 19036 KB | Output is correct |
17 | Correct | 12 ms | 19032 KB | Output is correct |
18 | Correct | 11 ms | 19276 KB | Output is correct |
19 | Correct | 11 ms | 19036 KB | Output is correct |
20 | Correct | 11 ms | 19036 KB | Output is correct |
21 | Correct | 11 ms | 19268 KB | Output is correct |
22 | Correct | 11 ms | 19036 KB | Output is correct |
23 | Correct | 11 ms | 19288 KB | Output is correct |
24 | Correct | 11 ms | 19036 KB | Output is correct |
25 | Correct | 11 ms | 19036 KB | Output is correct |
26 | Correct | 11 ms | 19036 KB | Output is correct |
27 | Correct | 12 ms | 19180 KB | Output is correct |
28 | Correct | 11 ms | 19036 KB | Output is correct |
29 | Correct | 11 ms | 19292 KB | Output is correct |
30 | Correct | 12 ms | 19180 KB | Output is correct |
31 | Correct | 11 ms | 19036 KB | Output is correct |
32 | Correct | 11 ms | 19292 KB | Output is correct |
33 | Correct | 11 ms | 19036 KB | Output is correct |
34 | Correct | 11 ms | 19036 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 19032 KB | Output is correct |
2 | Correct | 11 ms | 19036 KB | Output is correct |
3 | Correct | 11 ms | 19164 KB | Output is correct |
4 | Correct | 11 ms | 19036 KB | Output is correct |
5 | Correct | 11 ms | 19032 KB | Output is correct |
6 | Correct | 11 ms | 19036 KB | Output is correct |
7 | Correct | 11 ms | 19032 KB | Output is correct |
8 | Correct | 11 ms | 19036 KB | Output is correct |
9 | Correct | 11 ms | 19164 KB | Output is correct |
10 | Correct | 11 ms | 19108 KB | Output is correct |
11 | Correct | 11 ms | 19180 KB | Output is correct |
12 | Correct | 12 ms | 19032 KB | Output is correct |
13 | Correct | 13 ms | 19292 KB | Output is correct |
14 | Correct | 11 ms | 19036 KB | Output is correct |
15 | Correct | 11 ms | 19036 KB | Output is correct |
16 | Correct | 12 ms | 19036 KB | Output is correct |
17 | Correct | 12 ms | 19032 KB | Output is correct |
18 | Correct | 11 ms | 19276 KB | Output is correct |
19 | Correct | 11 ms | 19036 KB | Output is correct |
20 | Correct | 11 ms | 19036 KB | Output is correct |
21 | Correct | 11 ms | 19268 KB | Output is correct |
22 | Correct | 11 ms | 19036 KB | Output is correct |
23 | Correct | 11 ms | 19288 KB | Output is correct |
24 | Correct | 11 ms | 19036 KB | Output is correct |
25 | Correct | 11 ms | 19036 KB | Output is correct |
26 | Correct | 11 ms | 19036 KB | Output is correct |
27 | Correct | 12 ms | 19180 KB | Output is correct |
28 | Correct | 11 ms | 19036 KB | Output is correct |
29 | Correct | 11 ms | 19292 KB | Output is correct |
30 | Correct | 12 ms | 19180 KB | Output is correct |
31 | Correct | 11 ms | 19036 KB | Output is correct |
32 | Correct | 11 ms | 19292 KB | Output is correct |
33 | Correct | 11 ms | 19036 KB | Output is correct |
34 | Correct | 11 ms | 19036 KB | Output is correct |
35 | Correct | 43 ms | 31568 KB | Output is correct |
36 | Correct | 50 ms | 31568 KB | Output is correct |
37 | Correct | 48 ms | 31572 KB | Output is correct |
38 | Correct | 47 ms | 31572 KB | Output is correct |
39 | Correct | 42 ms | 31568 KB | Output is correct |
40 | Correct | 46 ms | 31572 KB | Output is correct |
41 | Correct | 47 ms | 31632 KB | Output is correct |
42 | Correct | 44 ms | 31644 KB | Output is correct |
43 | Correct | 43 ms | 31568 KB | Output is correct |
44 | Correct | 43 ms | 31632 KB | Output is correct |
45 | Correct | 55 ms | 31640 KB | Output is correct |
46 | Correct | 43 ms | 31648 KB | Output is correct |
47 | Correct | 43 ms | 31636 KB | Output is correct |
48 | Correct | 49 ms | 31636 KB | Output is correct |
49 | Correct | 52 ms | 31572 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 19032 KB | Output is correct |
2 | Correct | 11 ms | 19036 KB | Output is correct |
3 | Correct | 11 ms | 19164 KB | Output is correct |
4 | Correct | 11 ms | 19036 KB | Output is correct |
5 | Correct | 11 ms | 19032 KB | Output is correct |
6 | Correct | 11 ms | 19036 KB | Output is correct |
7 | Correct | 11 ms | 19032 KB | Output is correct |
8 | Correct | 11 ms | 19036 KB | Output is correct |
9 | Correct | 11 ms | 19164 KB | Output is correct |
10 | Correct | 11 ms | 19108 KB | Output is correct |
11 | Correct | 11 ms | 19180 KB | Output is correct |
12 | Correct | 12 ms | 19032 KB | Output is correct |
13 | Correct | 13 ms | 19292 KB | Output is correct |
14 | Correct | 11 ms | 19036 KB | Output is correct |
15 | Correct | 11 ms | 19036 KB | Output is correct |
16 | Correct | 12 ms | 19036 KB | Output is correct |
17 | Correct | 12 ms | 19032 KB | Output is correct |
18 | Correct | 11 ms | 19276 KB | Output is correct |
19 | Correct | 11 ms | 19036 KB | Output is correct |
20 | Correct | 11 ms | 19036 KB | Output is correct |
21 | Correct | 11 ms | 19268 KB | Output is correct |
22 | Correct | 11 ms | 19036 KB | Output is correct |
23 | Correct | 11 ms | 19288 KB | Output is correct |
24 | Correct | 11 ms | 19036 KB | Output is correct |
25 | Correct | 11 ms | 19036 KB | Output is correct |
26 | Correct | 11 ms | 19036 KB | Output is correct |
27 | Correct | 12 ms | 19180 KB | Output is correct |
28 | Correct | 11 ms | 19036 KB | Output is correct |
29 | Correct | 11 ms | 19292 KB | Output is correct |
30 | Correct | 12 ms | 19180 KB | Output is correct |
31 | Correct | 11 ms | 19036 KB | Output is correct |
32 | Correct | 11 ms | 19292 KB | Output is correct |
33 | Correct | 11 ms | 19036 KB | Output is correct |
34 | Correct | 11 ms | 19036 KB | Output is correct |
35 | Correct | 43 ms | 31568 KB | Output is correct |
36 | Correct | 50 ms | 31568 KB | Output is correct |
37 | Correct | 48 ms | 31572 KB | Output is correct |
38 | Correct | 47 ms | 31572 KB | Output is correct |
39 | Correct | 42 ms | 31568 KB | Output is correct |
40 | Correct | 46 ms | 31572 KB | Output is correct |
41 | Correct | 47 ms | 31632 KB | Output is correct |
42 | Correct | 44 ms | 31644 KB | Output is correct |
43 | Correct | 43 ms | 31568 KB | Output is correct |
44 | Correct | 43 ms | 31632 KB | Output is correct |
45 | Correct | 55 ms | 31640 KB | Output is correct |
46 | Correct | 43 ms | 31648 KB | Output is correct |
47 | Correct | 43 ms | 31636 KB | Output is correct |
48 | Correct | 49 ms | 31636 KB | Output is correct |
49 | Correct | 52 ms | 31572 KB | Output is correct |
50 | Correct | 55 ms | 31572 KB | Output is correct |
51 | Correct | 55 ms | 31640 KB | Output is correct |
52 | Correct | 69 ms | 31572 KB | Output is correct |
53 | Correct | 53 ms | 31568 KB | Output is correct |
54 | Correct | 53 ms | 31572 KB | Output is correct |
55 | Correct | 67 ms | 31572 KB | Output is correct |
56 | Correct | 68 ms | 31632 KB | Output is correct |
57 | Correct | 48 ms | 31572 KB | Output is correct |
58 | Correct | 51 ms | 31636 KB | Output is correct |
59 | Correct | 60 ms | 31568 KB | Output is correct |
60 | Correct | 59 ms | 31572 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 19032 KB | Output is correct |
2 | Correct | 11 ms | 19036 KB | Output is correct |
3 | Correct | 11 ms | 19164 KB | Output is correct |
4 | Correct | 11 ms | 19036 KB | Output is correct |
5 | Correct | 11 ms | 19032 KB | Output is correct |
6 | Correct | 11 ms | 19036 KB | Output is correct |
7 | Correct | 11 ms | 19032 KB | Output is correct |
8 | Correct | 11 ms | 19036 KB | Output is correct |
9 | Correct | 11 ms | 19164 KB | Output is correct |
10 | Correct | 11 ms | 19108 KB | Output is correct |
11 | Correct | 11 ms | 19180 KB | Output is correct |
12 | Correct | 12 ms | 19032 KB | Output is correct |
13 | Correct | 13 ms | 19292 KB | Output is correct |
14 | Correct | 11 ms | 19036 KB | Output is correct |
15 | Correct | 11 ms | 19036 KB | Output is correct |
16 | Correct | 12 ms | 19036 KB | Output is correct |
17 | Correct | 12 ms | 19032 KB | Output is correct |
18 | Correct | 11 ms | 19276 KB | Output is correct |
19 | Correct | 11 ms | 19036 KB | Output is correct |
20 | Correct | 11 ms | 19036 KB | Output is correct |
21 | Correct | 11 ms | 19268 KB | Output is correct |
22 | Correct | 11 ms | 19036 KB | Output is correct |
23 | Correct | 11 ms | 19288 KB | Output is correct |
24 | Correct | 11 ms | 19036 KB | Output is correct |
25 | Correct | 11 ms | 19036 KB | Output is correct |
26 | Correct | 11 ms | 19036 KB | Output is correct |
27 | Correct | 12 ms | 19180 KB | Output is correct |
28 | Correct | 11 ms | 19036 KB | Output is correct |
29 | Correct | 11 ms | 19292 KB | Output is correct |
30 | Correct | 12 ms | 19180 KB | Output is correct |
31 | Correct | 11 ms | 19036 KB | Output is correct |
32 | Correct | 11 ms | 19292 KB | Output is correct |
33 | Correct | 11 ms | 19036 KB | Output is correct |
34 | Correct | 11 ms | 19036 KB | Output is correct |
35 | Correct | 43 ms | 31568 KB | Output is correct |
36 | Correct | 50 ms | 31568 KB | Output is correct |
37 | Correct | 48 ms | 31572 KB | Output is correct |
38 | Correct | 47 ms | 31572 KB | Output is correct |
39 | Correct | 42 ms | 31568 KB | Output is correct |
40 | Correct | 46 ms | 31572 KB | Output is correct |
41 | Correct | 47 ms | 31632 KB | Output is correct |
42 | Correct | 44 ms | 31644 KB | Output is correct |
43 | Correct | 43 ms | 31568 KB | Output is correct |
44 | Correct | 43 ms | 31632 KB | Output is correct |
45 | Correct | 55 ms | 31640 KB | Output is correct |
46 | Correct | 43 ms | 31648 KB | Output is correct |
47 | Correct | 43 ms | 31636 KB | Output is correct |
48 | Correct | 49 ms | 31636 KB | Output is correct |
49 | Correct | 52 ms | 31572 KB | Output is correct |
50 | Correct | 55 ms | 31572 KB | Output is correct |
51 | Correct | 55 ms | 31640 KB | Output is correct |
52 | Correct | 69 ms | 31572 KB | Output is correct |
53 | Correct | 53 ms | 31568 KB | Output is correct |
54 | Correct | 53 ms | 31572 KB | Output is correct |
55 | Correct | 67 ms | 31572 KB | Output is correct |
56 | Correct | 68 ms | 31632 KB | Output is correct |
57 | Correct | 48 ms | 31572 KB | Output is correct |
58 | Correct | 51 ms | 31636 KB | Output is correct |
59 | Correct | 60 ms | 31568 KB | Output is correct |
60 | Correct | 59 ms | 31572 KB | Output is correct |
61 | Correct | 12 ms | 25432 KB | Output is correct |
62 | Correct | 13 ms | 25316 KB | Output is correct |
63 | Correct | 11 ms | 25180 KB | Output is correct |
64 | Correct | 12 ms | 25436 KB | Output is correct |
65 | Correct | 35 ms | 29588 KB | Output is correct |
66 | Correct | 30 ms | 29592 KB | Output is correct |
67 | Correct | 56 ms | 31568 KB | Output is correct |
68 | Correct | 16 ms | 27480 KB | Output is correct |
69 | Correct | 13 ms | 25324 KB | Output is correct |
70 | Correct | 12 ms | 25428 KB | Output is correct |
71 | Correct | 11 ms | 25436 KB | Output is correct |