답안 #653486

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
653486 2022-10-27T01:32:07 Z Lobo 디지털 회로 (IOI22_circuit) C++17
22 / 100
3000 ms 13200 KB
#include "circuit.h"
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()

const int maxn = 2e5+10;
const int mod = 1000002022;
int n, m, p[maxn], a[maxn];
vector<int> g[maxn];
int c[maxn], pw2[maxn], prd[maxn];

void dfssz(int u) {
    c[u] = g[u].size();
    if(u >= n) c[u] = 1;
    if(u >= n) return;
    for(auto v : g[u]) {
        dfssz(v);
        c[u] = c[u]*c[v]%mod;
    }
}

void dfs(int u) {
    vector<int> pf(g[u].size()+1), sf(g[u].size()+1);

    for(int i = 0; i < (int) g[u].size(); i++) {
        int v = g[u][i];
        pf[i] = c[v];
        if(i!=0) pf[i] = pf[i]*pf[i-1]%mod;
    }
    for(int i = (int) g[u].size()-1; i >= 0; i--) {
        int v = g[u][i];
        sf[i] = c[v];
        if(i != (int) g[u].size()-1) sf[i] = sf[i]*sf[i+1]%mod;
    }

    for(int i = 0; i < (int) g[u].size(); i++) {
        int v = g[u][i];
        prd[v] = prd[u];
        if(i != 0) prd[v] = prd[v]*pf[i-1]%mod;
        if(i != (int) g[u].size()-1) prd[v] = prd[v]*sf[i+1]%mod;
    }

    for(auto v : g[u]) {
        dfs(v);
    }
}

int ans = 0;
void init(int32_t N, int32_t M, vector<int32_t> P, vector<int32_t> A) {
    n = N;
    m = M;
    for(int i = 1; i < n+m; i++) {
        p[i] = P[i];
        g[p[i]].pb(i);
    }
    for(int i = 0; i < m; i++) {
        a[i] = A[i];
    }
    pw2[0] = 1;
    for(int i = 1; i <= n+m; i++) {
        pw2[i] = pw2[i-1]*2%mod;
    }
    dfssz(0);
    prd[0] = 1;
    dfs(0);
    for(int i = n; i < n+m; i++) ans+= a[i-n]*prd[i];
    for(int i = 0; i < n+m; i++) {
        // cout << i << " =  " << c[i] << " " << prd[i] << endl;
    }
}
int32_t count_ways(int32_t L, int32_t R) {
    for(int i = L; i <= R; i++) {
        ans-= a[i-n]*prd[i]; ans%=mod; ans+= mod; ans%= mod;
        a[i-n]^=1;
        ans+= a[i-n]*prd[i]; ans%=mod;
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4944 KB Output is correct
2 Correct 3 ms 4944 KB Output is correct
3 Correct 4 ms 5072 KB Output is correct
4 Correct 3 ms 5068 KB Output is correct
5 Correct 3 ms 5072 KB Output is correct
6 Correct 3 ms 5012 KB Output is correct
7 Correct 3 ms 5076 KB Output is correct
8 Correct 3 ms 5072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4944 KB Output is correct
2 Correct 4 ms 4944 KB Output is correct
3 Correct 3 ms 5072 KB Output is correct
4 Correct 4 ms 5072 KB Output is correct
5 Correct 4 ms 5072 KB Output is correct
6 Correct 3 ms 5072 KB Output is correct
7 Correct 3 ms 5072 KB Output is correct
8 Correct 3 ms 5072 KB Output is correct
9 Correct 4 ms 5072 KB Output is correct
10 Correct 4 ms 5224 KB Output is correct
11 Correct 4 ms 5328 KB Output is correct
12 Correct 3 ms 5072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4944 KB Output is correct
2 Correct 3 ms 4944 KB Output is correct
3 Correct 4 ms 5072 KB Output is correct
4 Correct 3 ms 5068 KB Output is correct
5 Correct 3 ms 5072 KB Output is correct
6 Correct 3 ms 5012 KB Output is correct
7 Correct 3 ms 5076 KB Output is correct
8 Correct 3 ms 5072 KB Output is correct
9 Correct 4 ms 4944 KB Output is correct
10 Correct 4 ms 4944 KB Output is correct
11 Correct 3 ms 5072 KB Output is correct
12 Correct 4 ms 5072 KB Output is correct
13 Correct 4 ms 5072 KB Output is correct
14 Correct 3 ms 5072 KB Output is correct
15 Correct 3 ms 5072 KB Output is correct
16 Correct 3 ms 5072 KB Output is correct
17 Correct 4 ms 5072 KB Output is correct
18 Correct 4 ms 5224 KB Output is correct
19 Correct 4 ms 5328 KB Output is correct
20 Correct 3 ms 5072 KB Output is correct
21 Correct 4 ms 5072 KB Output is correct
22 Correct 4 ms 5072 KB Output is correct
23 Correct 3 ms 5072 KB Output is correct
24 Correct 3 ms 5072 KB Output is correct
25 Correct 4 ms 5056 KB Output is correct
26 Correct 3 ms 5072 KB Output is correct
27 Correct 3 ms 5072 KB Output is correct
28 Correct 3 ms 5072 KB Output is correct
29 Correct 4 ms 5072 KB Output is correct
30 Correct 3 ms 5072 KB Output is correct
31 Correct 4 ms 5200 KB Output is correct
32 Correct 3 ms 5072 KB Output is correct
33 Correct 3 ms 5072 KB Output is correct
34 Correct 3 ms 5072 KB Output is correct
35 Correct 3 ms 5072 KB Output is correct
36 Correct 3 ms 5328 KB Output is correct
37 Correct 3 ms 5328 KB Output is correct
38 Correct 3 ms 5328 KB Output is correct
39 Correct 4 ms 5200 KB Output is correct
40 Correct 3 ms 5072 KB Output is correct
41 Correct 4 ms 5072 KB Output is correct
42 Correct 3 ms 5072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 703 ms 9032 KB Output is correct
2 Correct 803 ms 13188 KB Output is correct
3 Correct 954 ms 13200 KB Output is correct
4 Correct 825 ms 13200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 703 ms 9032 KB Output is correct
2 Correct 803 ms 13188 KB Output is correct
3 Correct 954 ms 13200 KB Output is correct
4 Correct 825 ms 13200 KB Output is correct
5 Execution timed out 3066 ms 9104 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4944 KB Output is correct
2 Correct 4 ms 4944 KB Output is correct
3 Correct 3 ms 5072 KB Output is correct
4 Correct 4 ms 5072 KB Output is correct
5 Correct 4 ms 5072 KB Output is correct
6 Correct 3 ms 5072 KB Output is correct
7 Correct 3 ms 5072 KB Output is correct
8 Correct 3 ms 5072 KB Output is correct
9 Correct 4 ms 5072 KB Output is correct
10 Correct 4 ms 5224 KB Output is correct
11 Correct 4 ms 5328 KB Output is correct
12 Correct 3 ms 5072 KB Output is correct
13 Correct 703 ms 9032 KB Output is correct
14 Correct 803 ms 13188 KB Output is correct
15 Correct 954 ms 13200 KB Output is correct
16 Correct 825 ms 13200 KB Output is correct
17 Execution timed out 3066 ms 9104 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4944 KB Output is correct
2 Correct 3 ms 4944 KB Output is correct
3 Correct 4 ms 5072 KB Output is correct
4 Correct 3 ms 5068 KB Output is correct
5 Correct 3 ms 5072 KB Output is correct
6 Correct 3 ms 5012 KB Output is correct
7 Correct 3 ms 5076 KB Output is correct
8 Correct 3 ms 5072 KB Output is correct
9 Correct 4 ms 4944 KB Output is correct
10 Correct 4 ms 4944 KB Output is correct
11 Correct 3 ms 5072 KB Output is correct
12 Correct 4 ms 5072 KB Output is correct
13 Correct 4 ms 5072 KB Output is correct
14 Correct 3 ms 5072 KB Output is correct
15 Correct 3 ms 5072 KB Output is correct
16 Correct 3 ms 5072 KB Output is correct
17 Correct 4 ms 5072 KB Output is correct
18 Correct 4 ms 5224 KB Output is correct
19 Correct 4 ms 5328 KB Output is correct
20 Correct 3 ms 5072 KB Output is correct
21 Correct 4 ms 5072 KB Output is correct
22 Correct 4 ms 5072 KB Output is correct
23 Correct 3 ms 5072 KB Output is correct
24 Correct 3 ms 5072 KB Output is correct
25 Correct 4 ms 5056 KB Output is correct
26 Correct 3 ms 5072 KB Output is correct
27 Correct 3 ms 5072 KB Output is correct
28 Correct 3 ms 5072 KB Output is correct
29 Correct 4 ms 5072 KB Output is correct
30 Correct 3 ms 5072 KB Output is correct
31 Correct 4 ms 5200 KB Output is correct
32 Correct 3 ms 5072 KB Output is correct
33 Correct 3 ms 5072 KB Output is correct
34 Correct 3 ms 5072 KB Output is correct
35 Correct 3 ms 5072 KB Output is correct
36 Correct 3 ms 5328 KB Output is correct
37 Correct 3 ms 5328 KB Output is correct
38 Correct 3 ms 5328 KB Output is correct
39 Correct 4 ms 5200 KB Output is correct
40 Correct 3 ms 5072 KB Output is correct
41 Correct 4 ms 5072 KB Output is correct
42 Correct 3 ms 5072 KB Output is correct
43 Correct 1311 ms 5328 KB Output is correct
44 Correct 1912 ms 5456 KB Output is correct
45 Correct 1846 ms 5328 KB Output is correct
46 Correct 734 ms 5640 KB Output is correct
47 Correct 2790 ms 5576 KB Output is correct
48 Correct 2627 ms 5636 KB Output is correct
49 Correct 2708 ms 5584 KB Output is correct
50 Execution timed out 3063 ms 5584 KB Time limit exceeded
51 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4944 KB Output is correct
2 Correct 3 ms 4944 KB Output is correct
3 Correct 4 ms 5072 KB Output is correct
4 Correct 3 ms 5068 KB Output is correct
5 Correct 3 ms 5072 KB Output is correct
6 Correct 3 ms 5012 KB Output is correct
7 Correct 3 ms 5076 KB Output is correct
8 Correct 3 ms 5072 KB Output is correct
9 Correct 4 ms 4944 KB Output is correct
10 Correct 4 ms 4944 KB Output is correct
11 Correct 3 ms 5072 KB Output is correct
12 Correct 4 ms 5072 KB Output is correct
13 Correct 4 ms 5072 KB Output is correct
14 Correct 3 ms 5072 KB Output is correct
15 Correct 3 ms 5072 KB Output is correct
16 Correct 3 ms 5072 KB Output is correct
17 Correct 4 ms 5072 KB Output is correct
18 Correct 4 ms 5224 KB Output is correct
19 Correct 4 ms 5328 KB Output is correct
20 Correct 3 ms 5072 KB Output is correct
21 Correct 4 ms 5072 KB Output is correct
22 Correct 4 ms 5072 KB Output is correct
23 Correct 3 ms 5072 KB Output is correct
24 Correct 3 ms 5072 KB Output is correct
25 Correct 4 ms 5056 KB Output is correct
26 Correct 3 ms 5072 KB Output is correct
27 Correct 3 ms 5072 KB Output is correct
28 Correct 3 ms 5072 KB Output is correct
29 Correct 4 ms 5072 KB Output is correct
30 Correct 3 ms 5072 KB Output is correct
31 Correct 4 ms 5200 KB Output is correct
32 Correct 3 ms 5072 KB Output is correct
33 Correct 3 ms 5072 KB Output is correct
34 Correct 3 ms 5072 KB Output is correct
35 Correct 3 ms 5072 KB Output is correct
36 Correct 3 ms 5328 KB Output is correct
37 Correct 3 ms 5328 KB Output is correct
38 Correct 3 ms 5328 KB Output is correct
39 Correct 4 ms 5200 KB Output is correct
40 Correct 3 ms 5072 KB Output is correct
41 Correct 4 ms 5072 KB Output is correct
42 Correct 3 ms 5072 KB Output is correct
43 Correct 703 ms 9032 KB Output is correct
44 Correct 803 ms 13188 KB Output is correct
45 Correct 954 ms 13200 KB Output is correct
46 Correct 825 ms 13200 KB Output is correct
47 Execution timed out 3066 ms 9104 KB Time limit exceeded
48 Halted 0 ms 0 KB -