# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
792405 | 2023-07-25T04:17:38 Z | 반딧불(#10051) | Binaria (CCO23_day1problem1) | C++17 | 139 ms | 35516 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD = 1000003; ll mpow(ll x, ll y){ if(y==0) return 1; if(y&1) return mpow(x, y-1) * x % MOD; ll tmp = mpow(x, y/2); return tmp * tmp % MOD; } ll modInv(ll x){ return mpow(x, MOD-2); } void imp(){ printf("0"); exit(0); } int n, k; int arr[1000002]; ll offset[1000002]; /// arr[i] ��� (k+1)�� �������� ���� ������ ���̰� �� ���°�? ll seq[1000002]; bool notDecided[1000002]; ll fact[1000002]; ll factInv[1000002]; int main(){ scanf("%d %d", &n, &k); for(int i=0; i<n-k+1; i++){ scanf("%d", &arr[i]); if(arr[i] < 0 || arr[i] > k) imp(); } for(int i=k; i<n; i++){ offset[i] = offset[i-k] + (arr[i-k+1] - arr[i-k]); } for(int s=0; s<k; s++){ ll minOffset = 0, maxOffset = 0; for(int i=s; i<n; i+=k) minOffset = min(minOffset, offset[i]), maxOffset = max(maxOffset, offset[i]); if(maxOffset - minOffset >= 2) imp(); if(minOffset != maxOffset){ for(int i=s; i<n; i+=k) seq[i] = offset[i] - minOffset; } else notDecided[s] = 1; } fact[0] = 1; for(int i=1; i<=n; i++) fact[i] = fact[i-1] * i % MOD; factInv[n] = modInv(fact[n]); for(int i=n-1; i>=0; i--) factInv[i] = factInv[i+1] * (i+1) % MOD; ll leftSum = arr[0], cnt = 0; for(int s=0; s<k; s++){ if(notDecided[s]) cnt++; else leftSum -= seq[s]; } if(leftSum > cnt) imp(); printf("%lld", fact[cnt] * factInv[leftSum] % MOD * factInv[cnt-leftSum] % MOD); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 340 KB | Output is correct |
17 | Correct | 0 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 0 ms | 340 KB | Output is correct |
20 | Correct | 0 ms | 340 KB | Output is correct |
21 | Correct | 0 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 340 KB | Output is correct |
17 | Correct | 0 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 0 ms | 340 KB | Output is correct |
20 | Correct | 0 ms | 340 KB | Output is correct |
21 | Correct | 0 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 0 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 0 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 0 ms | 340 KB | Output is correct |
28 | Correct | 0 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 1 ms | 340 KB | Output is correct |
31 | Correct | 0 ms | 340 KB | Output is correct |
32 | Correct | 0 ms | 340 KB | Output is correct |
33 | Correct | 0 ms | 340 KB | Output is correct |
34 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 340 KB | Output is correct |
17 | Correct | 0 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 0 ms | 340 KB | Output is correct |
20 | Correct | 0 ms | 340 KB | Output is correct |
21 | Correct | 0 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 0 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 0 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 0 ms | 340 KB | Output is correct |
28 | Correct | 0 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 1 ms | 340 KB | Output is correct |
31 | Correct | 0 ms | 340 KB | Output is correct |
32 | Correct | 0 ms | 340 KB | Output is correct |
33 | Correct | 0 ms | 340 KB | Output is correct |
34 | Correct | 1 ms | 340 KB | Output is correct |
35 | Correct | 94 ms | 27644 KB | Output is correct |
36 | Correct | 94 ms | 35452 KB | Output is correct |
37 | Correct | 100 ms | 35400 KB | Output is correct |
38 | Correct | 95 ms | 35412 KB | Output is correct |
39 | Correct | 96 ms | 27644 KB | Output is correct |
40 | Correct | 92 ms | 27680 KB | Output is correct |
41 | Correct | 90 ms | 35484 KB | Output is correct |
42 | Correct | 111 ms | 35496 KB | Output is correct |
43 | Correct | 93 ms | 35392 KB | Output is correct |
44 | Correct | 104 ms | 27640 KB | Output is correct |
45 | Correct | 104 ms | 35424 KB | Output is correct |
46 | Correct | 106 ms | 27696 KB | Output is correct |
47 | Correct | 90 ms | 27624 KB | Output is correct |
48 | Correct | 84 ms | 27684 KB | Output is correct |
49 | Correct | 85 ms | 35500 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 340 KB | Output is correct |
17 | Correct | 0 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 0 ms | 340 KB | Output is correct |
20 | Correct | 0 ms | 340 KB | Output is correct |
21 | Correct | 0 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 0 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 0 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 0 ms | 340 KB | Output is correct |
28 | Correct | 0 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 1 ms | 340 KB | Output is correct |
31 | Correct | 0 ms | 340 KB | Output is correct |
32 | Correct | 0 ms | 340 KB | Output is correct |
33 | Correct | 0 ms | 340 KB | Output is correct |
34 | Correct | 1 ms | 340 KB | Output is correct |
35 | Correct | 94 ms | 27644 KB | Output is correct |
36 | Correct | 94 ms | 35452 KB | Output is correct |
37 | Correct | 100 ms | 35400 KB | Output is correct |
38 | Correct | 95 ms | 35412 KB | Output is correct |
39 | Correct | 96 ms | 27644 KB | Output is correct |
40 | Correct | 92 ms | 27680 KB | Output is correct |
41 | Correct | 90 ms | 35484 KB | Output is correct |
42 | Correct | 111 ms | 35496 KB | Output is correct |
43 | Correct | 93 ms | 35392 KB | Output is correct |
44 | Correct | 104 ms | 27640 KB | Output is correct |
45 | Correct | 104 ms | 35424 KB | Output is correct |
46 | Correct | 106 ms | 27696 KB | Output is correct |
47 | Correct | 90 ms | 27624 KB | Output is correct |
48 | Correct | 84 ms | 27684 KB | Output is correct |
49 | Correct | 85 ms | 35500 KB | Output is correct |
50 | Correct | 98 ms | 27572 KB | Output is correct |
51 | Correct | 93 ms | 27596 KB | Output is correct |
52 | Correct | 90 ms | 35376 KB | Output is correct |
53 | Correct | 92 ms | 35404 KB | Output is correct |
54 | Correct | 108 ms | 35448 KB | Output is correct |
55 | Correct | 108 ms | 35504 KB | Output is correct |
56 | Correct | 90 ms | 35428 KB | Output is correct |
57 | Correct | 90 ms | 35440 KB | Output is correct |
58 | Correct | 111 ms | 27596 KB | Output is correct |
59 | Correct | 139 ms | 35476 KB | Output is correct |
60 | Correct | 126 ms | 35516 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 340 KB | Output is correct |
17 | Correct | 0 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 0 ms | 340 KB | Output is correct |
20 | Correct | 0 ms | 340 KB | Output is correct |
21 | Correct | 0 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 0 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 0 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 0 ms | 340 KB | Output is correct |
28 | Correct | 0 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 1 ms | 340 KB | Output is correct |
31 | Correct | 0 ms | 340 KB | Output is correct |
32 | Correct | 0 ms | 340 KB | Output is correct |
33 | Correct | 0 ms | 340 KB | Output is correct |
34 | Correct | 1 ms | 340 KB | Output is correct |
35 | Correct | 94 ms | 27644 KB | Output is correct |
36 | Correct | 94 ms | 35452 KB | Output is correct |
37 | Correct | 100 ms | 35400 KB | Output is correct |
38 | Correct | 95 ms | 35412 KB | Output is correct |
39 | Correct | 96 ms | 27644 KB | Output is correct |
40 | Correct | 92 ms | 27680 KB | Output is correct |
41 | Correct | 90 ms | 35484 KB | Output is correct |
42 | Correct | 111 ms | 35496 KB | Output is correct |
43 | Correct | 93 ms | 35392 KB | Output is correct |
44 | Correct | 104 ms | 27640 KB | Output is correct |
45 | Correct | 104 ms | 35424 KB | Output is correct |
46 | Correct | 106 ms | 27696 KB | Output is correct |
47 | Correct | 90 ms | 27624 KB | Output is correct |
48 | Correct | 84 ms | 27684 KB | Output is correct |
49 | Correct | 85 ms | 35500 KB | Output is correct |
50 | Correct | 98 ms | 27572 KB | Output is correct |
51 | Correct | 93 ms | 27596 KB | Output is correct |
52 | Correct | 90 ms | 35376 KB | Output is correct |
53 | Correct | 92 ms | 35404 KB | Output is correct |
54 | Correct | 108 ms | 35448 KB | Output is correct |
55 | Correct | 108 ms | 35504 KB | Output is correct |
56 | Correct | 90 ms | 35428 KB | Output is correct |
57 | Correct | 90 ms | 35440 KB | Output is correct |
58 | Correct | 111 ms | 27596 KB | Output is correct |
59 | Correct | 139 ms | 35476 KB | Output is correct |
60 | Correct | 126 ms | 35516 KB | Output is correct |
61 | Correct | 19 ms | 16900 KB | Output is correct |
62 | Correct | 19 ms | 16920 KB | Output is correct |
63 | Correct | 21 ms | 16904 KB | Output is correct |
64 | Correct | 21 ms | 16904 KB | Output is correct |
65 | Correct | 60 ms | 30076 KB | Output is correct |
66 | Correct | 51 ms | 25968 KB | Output is correct |
67 | Correct | 86 ms | 33308 KB | Output is correct |
68 | Correct | 25 ms | 18508 KB | Output is correct |
69 | Correct | 19 ms | 16844 KB | Output is correct |
70 | Correct | 20 ms | 16944 KB | Output is correct |
71 | Correct | 20 ms | 16852 KB | Output is correct |