Submission #1059469

# Submission time Handle Problem Language Result Execution time Memory
1059469 2024-08-15T02:37:10 Z shiomusubi496 Digital Circuit (IOI22_circuit) C++17
18 / 100
3000 ms 4032 KB
#include "circuit.h"
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); --i)

#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)

using namespace std;

using ll = long long;

template<class T, class U> bool chmin(T& a, const U& b) { return a > b ? a = b, true : false; }
template<class T, class U> bool chmax(T& a, const U& b) { return a < b ? a = b, true : false; }


constexpr ll MOD = 1000002022;

int N, M;
vector<vector<int>> G;
vector<int> A;

void init(int N_, int M_, std::vector<int> P, std::vector<int> A_) {
    N = N_; M = M_;
    A = A_;
    G.assign(N, vector<int>());
    rep2 (i, 1, N + M) G[P[i]].push_back(i);
}

int count_ways(int L, int R) {
    L = L - N;
    R = R + 1 - N;
    rep2 (i, L, R) A[i] ^= 1;
    vector<ll> res(N + M), res2(N + M);
    rep (i, M) res[N + i] = A[i], res2[N + i] = 1;
    rrep (i, N) {
        for (int j : G[i]) {
            ll p = 1;
            for (int k : G[i]) {
                if (j != k) (p *= res2[k]) %= MOD;
            }
            (res[i] += p * res[j]) %= MOD;
        }
        ll p = G[i].size();
        for (int k : G[i]) (p *= res2[k]) %= MOD;
        res2[i] = p;
    }
    return res[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 17 ms 344 KB Output is correct
4 Correct 18 ms 344 KB Output is correct
5 Correct 18 ms 344 KB Output is correct
6 Correct 18 ms 344 KB Output is correct
7 Correct 18 ms 344 KB Output is correct
8 Correct 18 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 412 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 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 17 ms 344 KB Output is correct
4 Correct 18 ms 344 KB Output is correct
5 Correct 18 ms 344 KB Output is correct
6 Correct 18 ms 344 KB Output is correct
7 Correct 18 ms 344 KB Output is correct
8 Correct 18 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 412 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 0 ms 384 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 18 ms 344 KB Output is correct
30 Correct 18 ms 344 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 4 ms 344 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 18 ms 344 KB Output is correct
38 Correct 18 ms 344 KB Output is correct
39 Correct 0 ms 344 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 0 ms 344 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3081 ms 4032 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3081 ms 4032 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 412 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Execution timed out 3081 ms 4032 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 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 17 ms 344 KB Output is correct
4 Correct 18 ms 344 KB Output is correct
5 Correct 18 ms 344 KB Output is correct
6 Correct 18 ms 344 KB Output is correct
7 Correct 18 ms 344 KB Output is correct
8 Correct 18 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 412 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 0 ms 384 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 18 ms 344 KB Output is correct
30 Correct 18 ms 344 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 4 ms 344 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 18 ms 344 KB Output is correct
38 Correct 18 ms 344 KB Output is correct
39 Correct 0 ms 344 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 0 ms 344 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
43 Execution timed out 3021 ms 600 KB Time limit exceeded
44 Halted 0 ms 0 KB -
# 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 17 ms 344 KB Output is correct
4 Correct 18 ms 344 KB Output is correct
5 Correct 18 ms 344 KB Output is correct
6 Correct 18 ms 344 KB Output is correct
7 Correct 18 ms 344 KB Output is correct
8 Correct 18 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 412 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 0 ms 384 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 18 ms 344 KB Output is correct
30 Correct 18 ms 344 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 4 ms 344 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 18 ms 344 KB Output is correct
38 Correct 18 ms 344 KB Output is correct
39 Correct 0 ms 344 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 0 ms 344 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
43 Execution timed out 3081 ms 4032 KB Time limit exceeded
44 Halted 0 ms 0 KB -