Submission #630033

# Submission time Handle Problem Language Result Execution time Memory
630033 2022-08-15T14:44:58 Z qwerasdfzxcl Digital Circuit (IOI22_circuit) C++17
46 / 100
1002 ms 27540 KB
#include "circuit.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int MOD = 1'000'002'022;
vector<int> adj[100100];
int n, m, a[100100];

struct Seg1{
    ll tree[200200], sz;
    void init(int n){
        sz = n;
        for (int i=sz;i<sz*2;i++) tree[i] = adj[i-sz].size();
        for (int i=sz-1;i;i--) tree[i] = tree[i<<1] * tree[i<<1|1] % MOD;
    }
    void update(int p, int x){
        for (tree[p+=sz]=x;p>1;p>>=1) tree[p>>1] = tree[p] * tree[p^1] % MOD;
    }
}tree1;

struct Seg2{
    pair<ll, ll> tree[400400];
    int lazy[400400];
    pair<ll, ll> combine(pair<ll, ll> x, pair<ll, ll> y){return {(x.first + y.first)%MOD, (x.second + y.second)%MOD};}
    void init(int i, int l, int r){
        lazy[i] = 0;
        if (l==r) {tree[i] = {0, a[l]}; return;}
        int m = (l+r)>>1;
        init(i<<1, l, m); init(i<<1|1, m+1, r);
        tree[i] = combine(tree[i<<1], tree[i<<1|1]);
    }
    void propagate(int i, int l, int r){
        if (!lazy[i]) return;
        swap(tree[i].first, tree[i].second);
        if (l!=r){
            lazy[i<<1] ^= 1;
            lazy[i<<1|1] ^= 1;
        }
        lazy[i] = 0;
    }
    void update(int i, int l, int r, int s, int e){
        propagate(i, l, r);
        if (r<s || e<l) return;
        if (s<=l && r<=e){
            lazy[i] ^= 1;
            propagate(i, l, r);
            return;
        }
        int m = (l+r)>>1;
        update(i<<1, l, m, s, e); update(i<<1|1, m+1, r, s, e);
        tree[i] = combine(tree[i<<1], tree[i<<1|1]);
    }
}tree2;

void dfs(int s){
    if (s<=n) tree1.update(s, 1);
    else a[s-n] = tree1.tree[1];

    for (auto &v:adj[s]) dfs(v);

    if (s<=n) tree1.update(s, adj[s].size());
}

void init(int N, int M, std::vector<int> P, std::vector<int> A) {
    adj[0].push_back(0);
    n = N, m = M;

    for (int i=1;i<n+m;i++){
        adj[P[i]+1].push_back(i+1);
    }

    tree1.init(n+1);
    dfs(1);
    tree2.init(1, 1, m);

    for (int i=0;i<m;i++) if (A[i]) tree2.update(1, 1, m, i+1, i+1);
}

int count_ways(int L, int R) {
    tree2.update(1, 1, m, L-n+1, R-n+1);
    return tree2.tree[1].first;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8912 KB Output is correct
2 Correct 4 ms 8912 KB Output is correct
3 Correct 5 ms 8912 KB Output is correct
4 Correct 4 ms 8912 KB Output is correct
5 Correct 4 ms 8876 KB Output is correct
6 Correct 4 ms 8912 KB Output is correct
7 Correct 5 ms 8912 KB Output is correct
8 Correct 4 ms 8912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8912 KB Output is correct
2 Correct 4 ms 8912 KB Output is correct
3 Correct 4 ms 8912 KB Output is correct
4 Correct 4 ms 8912 KB Output is correct
5 Correct 4 ms 8912 KB Output is correct
6 Correct 4 ms 8912 KB Output is correct
7 Correct 6 ms 8912 KB Output is correct
8 Correct 5 ms 8912 KB Output is correct
9 Correct 4 ms 8912 KB Output is correct
10 Correct 6 ms 9024 KB Output is correct
11 Correct 5 ms 9048 KB Output is correct
12 Correct 4 ms 8912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8912 KB Output is correct
2 Correct 4 ms 8912 KB Output is correct
3 Correct 5 ms 8912 KB Output is correct
4 Correct 4 ms 8912 KB Output is correct
5 Correct 4 ms 8876 KB Output is correct
6 Correct 4 ms 8912 KB Output is correct
7 Correct 5 ms 8912 KB Output is correct
8 Correct 4 ms 8912 KB Output is correct
9 Correct 4 ms 8912 KB Output is correct
10 Correct 4 ms 8912 KB Output is correct
11 Correct 4 ms 8912 KB Output is correct
12 Correct 4 ms 8912 KB Output is correct
13 Correct 4 ms 8912 KB Output is correct
14 Correct 4 ms 8912 KB Output is correct
15 Correct 6 ms 8912 KB Output is correct
16 Correct 5 ms 8912 KB Output is correct
17 Correct 4 ms 8912 KB Output is correct
18 Correct 6 ms 9024 KB Output is correct
19 Correct 5 ms 9048 KB Output is correct
20 Correct 4 ms 8912 KB Output is correct
21 Correct 5 ms 8912 KB Output is correct
22 Correct 5 ms 8912 KB Output is correct
23 Correct 5 ms 8912 KB Output is correct
24 Correct 5 ms 8912 KB Output is correct
25 Correct 5 ms 8912 KB Output is correct
26 Correct 5 ms 8912 KB Output is correct
27 Correct 6 ms 8928 KB Output is correct
28 Correct 4 ms 8912 KB Output is correct
29 Correct 5 ms 8912 KB Output is correct
30 Correct 5 ms 8960 KB Output is correct
31 Correct 4 ms 8912 KB Output is correct
32 Correct 6 ms 8912 KB Output is correct
33 Correct 5 ms 8912 KB Output is correct
34 Correct 4 ms 8912 KB Output is correct
35 Correct 4 ms 8900 KB Output is correct
36 Correct 6 ms 9040 KB Output is correct
37 Correct 5 ms 9040 KB Output is correct
38 Correct 5 ms 9040 KB Output is correct
39 Correct 5 ms 8912 KB Output is correct
40 Correct 4 ms 8912 KB Output is correct
41 Correct 5 ms 8968 KB Output is correct
42 Correct 5 ms 8912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 651 ms 11604 KB Output is correct
2 Runtime error 44 ms 27540 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 651 ms 11604 KB Output is correct
2 Runtime error 44 ms 27540 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8912 KB Output is correct
2 Correct 4 ms 8912 KB Output is correct
3 Correct 4 ms 8912 KB Output is correct
4 Correct 4 ms 8912 KB Output is correct
5 Correct 4 ms 8912 KB Output is correct
6 Correct 4 ms 8912 KB Output is correct
7 Correct 6 ms 8912 KB Output is correct
8 Correct 5 ms 8912 KB Output is correct
9 Correct 4 ms 8912 KB Output is correct
10 Correct 6 ms 9024 KB Output is correct
11 Correct 5 ms 9048 KB Output is correct
12 Correct 4 ms 8912 KB Output is correct
13 Correct 651 ms 11604 KB Output is correct
14 Runtime error 44 ms 27540 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8912 KB Output is correct
2 Correct 4 ms 8912 KB Output is correct
3 Correct 5 ms 8912 KB Output is correct
4 Correct 4 ms 8912 KB Output is correct
5 Correct 4 ms 8876 KB Output is correct
6 Correct 4 ms 8912 KB Output is correct
7 Correct 5 ms 8912 KB Output is correct
8 Correct 4 ms 8912 KB Output is correct
9 Correct 4 ms 8912 KB Output is correct
10 Correct 4 ms 8912 KB Output is correct
11 Correct 4 ms 8912 KB Output is correct
12 Correct 4 ms 8912 KB Output is correct
13 Correct 4 ms 8912 KB Output is correct
14 Correct 4 ms 8912 KB Output is correct
15 Correct 6 ms 8912 KB Output is correct
16 Correct 5 ms 8912 KB Output is correct
17 Correct 4 ms 8912 KB Output is correct
18 Correct 6 ms 9024 KB Output is correct
19 Correct 5 ms 9048 KB Output is correct
20 Correct 4 ms 8912 KB Output is correct
21 Correct 5 ms 8912 KB Output is correct
22 Correct 5 ms 8912 KB Output is correct
23 Correct 5 ms 8912 KB Output is correct
24 Correct 5 ms 8912 KB Output is correct
25 Correct 5 ms 8912 KB Output is correct
26 Correct 5 ms 8912 KB Output is correct
27 Correct 6 ms 8928 KB Output is correct
28 Correct 4 ms 8912 KB Output is correct
29 Correct 5 ms 8912 KB Output is correct
30 Correct 5 ms 8960 KB Output is correct
31 Correct 4 ms 8912 KB Output is correct
32 Correct 6 ms 8912 KB Output is correct
33 Correct 5 ms 8912 KB Output is correct
34 Correct 4 ms 8912 KB Output is correct
35 Correct 4 ms 8900 KB Output is correct
36 Correct 6 ms 9040 KB Output is correct
37 Correct 5 ms 9040 KB Output is correct
38 Correct 5 ms 9040 KB Output is correct
39 Correct 5 ms 8912 KB Output is correct
40 Correct 4 ms 8912 KB Output is correct
41 Correct 5 ms 8968 KB Output is correct
42 Correct 5 ms 8912 KB Output is correct
43 Correct 576 ms 9168 KB Output is correct
44 Correct 893 ms 9168 KB Output is correct
45 Correct 923 ms 9168 KB Output is correct
46 Correct 755 ms 9296 KB Output is correct
47 Correct 844 ms 9296 KB Output is correct
48 Correct 577 ms 9364 KB Output is correct
49 Correct 826 ms 9296 KB Output is correct
50 Correct 791 ms 9296 KB Output is correct
51 Correct 858 ms 9144 KB Output is correct
52 Correct 768 ms 9040 KB Output is correct
53 Correct 887 ms 9424 KB Output is correct
54 Correct 913 ms 9296 KB Output is correct
55 Correct 678 ms 9168 KB Output is correct
56 Correct 646 ms 9168 KB Output is correct
57 Correct 790 ms 9120 KB Output is correct
58 Correct 905 ms 9552 KB Output is correct
59 Correct 851 ms 9636 KB Output is correct
60 Correct 620 ms 9636 KB Output is correct
61 Correct 1002 ms 9208 KB Output is correct
62 Correct 794 ms 9052 KB Output is correct
63 Correct 657 ms 9040 KB Output is correct
64 Correct 832 ms 9040 KB Output is correct
65 Correct 439 ms 9040 KB Output is correct
66 Correct 902 ms 9168 KB Output is correct
67 Correct 820 ms 9168 KB Output is correct
68 Correct 730 ms 9168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8912 KB Output is correct
2 Correct 4 ms 8912 KB Output is correct
3 Correct 5 ms 8912 KB Output is correct
4 Correct 4 ms 8912 KB Output is correct
5 Correct 4 ms 8876 KB Output is correct
6 Correct 4 ms 8912 KB Output is correct
7 Correct 5 ms 8912 KB Output is correct
8 Correct 4 ms 8912 KB Output is correct
9 Correct 4 ms 8912 KB Output is correct
10 Correct 4 ms 8912 KB Output is correct
11 Correct 4 ms 8912 KB Output is correct
12 Correct 4 ms 8912 KB Output is correct
13 Correct 4 ms 8912 KB Output is correct
14 Correct 4 ms 8912 KB Output is correct
15 Correct 6 ms 8912 KB Output is correct
16 Correct 5 ms 8912 KB Output is correct
17 Correct 4 ms 8912 KB Output is correct
18 Correct 6 ms 9024 KB Output is correct
19 Correct 5 ms 9048 KB Output is correct
20 Correct 4 ms 8912 KB Output is correct
21 Correct 5 ms 8912 KB Output is correct
22 Correct 5 ms 8912 KB Output is correct
23 Correct 5 ms 8912 KB Output is correct
24 Correct 5 ms 8912 KB Output is correct
25 Correct 5 ms 8912 KB Output is correct
26 Correct 5 ms 8912 KB Output is correct
27 Correct 6 ms 8928 KB Output is correct
28 Correct 4 ms 8912 KB Output is correct
29 Correct 5 ms 8912 KB Output is correct
30 Correct 5 ms 8960 KB Output is correct
31 Correct 4 ms 8912 KB Output is correct
32 Correct 6 ms 8912 KB Output is correct
33 Correct 5 ms 8912 KB Output is correct
34 Correct 4 ms 8912 KB Output is correct
35 Correct 4 ms 8900 KB Output is correct
36 Correct 6 ms 9040 KB Output is correct
37 Correct 5 ms 9040 KB Output is correct
38 Correct 5 ms 9040 KB Output is correct
39 Correct 5 ms 8912 KB Output is correct
40 Correct 4 ms 8912 KB Output is correct
41 Correct 5 ms 8968 KB Output is correct
42 Correct 5 ms 8912 KB Output is correct
43 Correct 651 ms 11604 KB Output is correct
44 Runtime error 44 ms 27540 KB Execution killed with signal 11
45 Halted 0 ms 0 KB -