Submission #792400

# Submission time Handle Problem Language Result Execution time Memory
792400 2023-07-25T04:12:36 Z 이성호(#10053) Binaria (CCO23_day1problem1) C++17
0 / 25
2 ms 4180 KB
#include <iostream>
#include <vector>
using namespace std;

int res[1000005];
int sum[1000005];
const int mod = 1000003;
int mul(int id, int x)
{
    if (x == 0) return 1;
    long long ans = mul(id, x / 2);
    ans = ans * ans % mod;
    return (x & 1) ? (ans * id % mod) : ans;
}
int rev(int x)
{
    return mul(x, mod - 2);
}
int main()
{
    int N, K; cin >> N >> K;
    for (int i = 1; i <= N - K + 1; i++) cin >> sum[i];
    fill(res, res + 1000005, -1);
    for (int i = 1; i <= N - K; i++) {
        if (sum[i+1] ^ sum[i]) {
            if (sum[i+1] - sum[i] == 1) {
                if (res[i+K] != 0) res[i+K] = 1;
                else {
                    cout << "0\n";
                    return 0;
                }
                if (res[i] != 1) res[i] = 0;
                else {
                    cout << "0\n";
                    return 0;
                }
            }
            else {
                if (res[i+K] != 1) res[i+K] = 0;
                else {
                    cout << "0\n";
                    return 0;
                }
                if (res[i] != 0) res[i] = 1;
                else {
                    cout << "0\n";
                    return 0;
                }
            }
        }
    }
    int tot = 0, cur = 0;
    for (int i = 1; i <= K; i++) {
        if (res[i] == -1) tot++;
        if (res[i] == 1) cur++;
    }
    cur = sum[1] - cur;
    if (cur < 0 || cur > tot) cout << "0\n";
    else {
        long long ans = 1;
        for (int i = tot; i >= tot - cur + 1; i--) {
            ans = ans * i % mod;
        }
        for (int i = 1; i <= cur; i++) {
            ans = ans * rev(i) % mod;
        }
        cout << ans << '\n';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 2 ms 4180 KB Output is correct
4 Correct 2 ms 4180 KB Output is correct
5 Correct 2 ms 4180 KB Output is correct
6 Incorrect 1 ms 4180 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 2 ms 4180 KB Output is correct
4 Correct 2 ms 4180 KB Output is correct
5 Correct 2 ms 4180 KB Output is correct
6 Incorrect 1 ms 4180 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 2 ms 4180 KB Output is correct
4 Correct 2 ms 4180 KB Output is correct
5 Correct 2 ms 4180 KB Output is correct
6 Incorrect 1 ms 4180 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 2 ms 4180 KB Output is correct
4 Correct 2 ms 4180 KB Output is correct
5 Correct 2 ms 4180 KB Output is correct
6 Incorrect 1 ms 4180 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 2 ms 4180 KB Output is correct
4 Correct 2 ms 4180 KB Output is correct
5 Correct 2 ms 4180 KB Output is correct
6 Incorrect 1 ms 4180 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 2 ms 4180 KB Output is correct
4 Correct 2 ms 4180 KB Output is correct
5 Correct 2 ms 4180 KB Output is correct
6 Incorrect 1 ms 4180 KB Output isn't correct
7 Halted 0 ms 0 KB -