Submission #1038817

# Submission time Handle Problem Language Result Execution time Memory
1038817 2024-07-30T07:57:32 Z vjudge1 Binaria (CCO23_day1problem1) C++17
25 / 25
106 ms 20948 KB
// Dit me fryingduc

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define fore(i, a, b) for (int i = (a); i <= (b); i++)
#define pb emplace_back
const int mod = 1e6 + 3;

int binpow(int a, int b)
{
  if (b == 0) return 1ll;
  int ans = binpow(a, b / 2ll);
  return ans * ans % mod * (b & 1ll ? a : 1ll) % mod;
}

int nCk(int n, int k)
{
  int ans = 1;
  if (k > n || n < 0 || k < 0) return 0;
  fore(i, k + 1, n) ans = ans * i % mod;
  fore(i, 1, n - k) ans = ans * binpow(i, mod - 2) % mod;
  return ans;
}

signed main()
{
  cin.tie(0)->sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n - k + 2), x(n + 1, -1);
  fore(i, 1, n - k + 1) cin >> a[i];
  fore(i, 2, n - k + 1) if (abs(a[i] - a[i - 1]) > 1) return cout << 0, 0;
  fore(i, 2, n - k + 1)
  {
    if (a[i] - a[i - 1] == 1) 
      x[i + k - 1] = 1,
      x[i - 1] = 0;
    else if (a[i] - a[i - 1] == -1)
      x[i + k - 1] = 0,
      x[i - 1] = 1;
    else
      x[i + k - 1] = x[i - 1];
  }
  for (int i = n - k; i >= 1; i--)
    if (a[i] == a[i + 1])
      x[i] = x[i + k];
  int use = 0;
  fore(i, 1, k)
    use += (x[i] == -1),
    a[1] -= (x[i] == 1);
  cout << nCk(use, a[1]);
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 372 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 452 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 372 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 452 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 39 ms 18028 KB Output is correct
36 Correct 39 ms 18520 KB Output is correct
37 Correct 42 ms 19028 KB Output is correct
38 Correct 52 ms 19028 KB Output is correct
39 Correct 36 ms 18004 KB Output is correct
40 Correct 46 ms 19024 KB Output is correct
41 Correct 43 ms 18920 KB Output is correct
42 Correct 42 ms 18004 KB Output is correct
43 Correct 42 ms 18000 KB Output is correct
44 Correct 38 ms 18008 KB Output is correct
45 Correct 38 ms 18024 KB Output is correct
46 Correct 43 ms 18024 KB Output is correct
47 Correct 38 ms 18004 KB Output is correct
48 Correct 43 ms 19028 KB Output is correct
49 Correct 42 ms 18928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 372 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 452 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 39 ms 18028 KB Output is correct
36 Correct 39 ms 18520 KB Output is correct
37 Correct 42 ms 19028 KB Output is correct
38 Correct 52 ms 19028 KB Output is correct
39 Correct 36 ms 18004 KB Output is correct
40 Correct 46 ms 19024 KB Output is correct
41 Correct 43 ms 18920 KB Output is correct
42 Correct 42 ms 18004 KB Output is correct
43 Correct 42 ms 18000 KB Output is correct
44 Correct 38 ms 18008 KB Output is correct
45 Correct 38 ms 18024 KB Output is correct
46 Correct 43 ms 18024 KB Output is correct
47 Correct 38 ms 18004 KB Output is correct
48 Correct 43 ms 19028 KB Output is correct
49 Correct 42 ms 18928 KB Output is correct
50 Correct 55 ms 20816 KB Output is correct
51 Correct 54 ms 20928 KB Output is correct
52 Correct 53 ms 20816 KB Output is correct
53 Correct 53 ms 20816 KB Output is correct
54 Correct 50 ms 20828 KB Output is correct
55 Correct 57 ms 20812 KB Output is correct
56 Correct 50 ms 20820 KB Output is correct
57 Correct 48 ms 19796 KB Output is correct
58 Correct 51 ms 20816 KB Output is correct
59 Correct 50 ms 20948 KB Output is correct
60 Correct 47 ms 19804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 372 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 452 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 39 ms 18028 KB Output is correct
36 Correct 39 ms 18520 KB Output is correct
37 Correct 42 ms 19028 KB Output is correct
38 Correct 52 ms 19028 KB Output is correct
39 Correct 36 ms 18004 KB Output is correct
40 Correct 46 ms 19024 KB Output is correct
41 Correct 43 ms 18920 KB Output is correct
42 Correct 42 ms 18004 KB Output is correct
43 Correct 42 ms 18000 KB Output is correct
44 Correct 38 ms 18008 KB Output is correct
45 Correct 38 ms 18024 KB Output is correct
46 Correct 43 ms 18024 KB Output is correct
47 Correct 38 ms 18004 KB Output is correct
48 Correct 43 ms 19028 KB Output is correct
49 Correct 42 ms 18928 KB Output is correct
50 Correct 55 ms 20816 KB Output is correct
51 Correct 54 ms 20928 KB Output is correct
52 Correct 53 ms 20816 KB Output is correct
53 Correct 53 ms 20816 KB Output is correct
54 Correct 50 ms 20828 KB Output is correct
55 Correct 57 ms 20812 KB Output is correct
56 Correct 50 ms 20820 KB Output is correct
57 Correct 48 ms 19796 KB Output is correct
58 Correct 51 ms 20816 KB Output is correct
59 Correct 50 ms 20948 KB Output is correct
60 Correct 47 ms 19804 KB Output is correct
61 Correct 54 ms 8284 KB Output is correct
62 Correct 66 ms 8284 KB Output is correct
63 Correct 16 ms 8284 KB Output is correct
64 Correct 50 ms 8236 KB Output is correct
65 Correct 47 ms 15616 KB Output is correct
66 Correct 59 ms 13140 KB Output is correct
67 Correct 55 ms 19796 KB Output is correct
68 Correct 101 ms 9564 KB Output is correct
69 Correct 3 ms 8280 KB Output is correct
70 Correct 106 ms 8284 KB Output is correct
71 Correct 53 ms 8280 KB Output is correct