답안 #1068951

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1068951 2024-08-21T13:42:26 Z beaconmc 디지털 회로 (IOI22_circuit) C++17
18 / 100
3000 ms 17384 KB
#include "circuit.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)

const ll maxn = 100005;

vector<ll> edges[maxn];
ll sub[maxn];
ll realsub[maxn];
ll par[maxn];
ll prod[maxn];




void dfs(ll a){
    prod[a] = 1;

    for (auto&i : edges[a]){
        dfs(i);

        prod[a] *= prod[i];
        prod[a] %= 1000002022;
    }
    if ( edges[a].size() != 0) prod[a] *= edges[a].size();
    prod[a] %= 1000002022;
}

ll cache[maxn];

ll dp(ll a){

    if (cache[a] != -1) return cache[a];
    if (a==0) return 1;


    cache[a] = dp(par[a]);
    for (auto&i : edges[par[a]]){
        if (i != a) cache[a] *= prod[i];
        cache[a] %= 1000002022;
    }



    return cache[a] %= 1000002022;
}
ll states[maxn];

ll ans = 0;

void init(int N, int M, std::vector<int> P, std::vector<int> A) {
    FOR(i,0,maxn) cache[i] = -1;
    par[0] = -1;
    FOR(i,1,N+M){
        edges[P[i]].push_back(i);
        par[i] = P[i];
    }
    dfs(0);

    FOR(i,0,M){
        states[N+i] = A[i];
        if (A[i]==1) ans += dp(N+i);
        ans %= 1000002022;
    }






}

int count_ways(int L, int R) {

    FOR(i,L,R+1){
        if (states[i]==1){
            states[i] = 0;
            ans -= dp(i);
        }else{
            states[i] = 1;
            ans += dp(i);
        }
        ans %= 1000002022;
    }
    return (ans+1000002022)%1000002022;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3928 KB Output is correct
2 Correct 1 ms 3416 KB Output is correct
3 Correct 5 ms 3416 KB Output is correct
4 Correct 4 ms 3416 KB Output is correct
5 Correct 5 ms 4048 KB Output is correct
6 Correct 5 ms 3416 KB Output is correct
7 Correct 6 ms 3636 KB Output is correct
8 Correct 4 ms 3416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3416 KB Output is correct
2 Correct 2 ms 3416 KB Output is correct
3 Correct 2 ms 3416 KB Output is correct
4 Correct 1 ms 3416 KB Output is correct
5 Correct 1 ms 3416 KB Output is correct
6 Correct 2 ms 3416 KB Output is correct
7 Correct 1 ms 3928 KB Output is correct
8 Correct 2 ms 3672 KB Output is correct
9 Correct 2 ms 3672 KB Output is correct
10 Correct 2 ms 3672 KB Output is correct
11 Correct 2 ms 3672 KB Output is correct
12 Correct 2 ms 3416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3928 KB Output is correct
2 Correct 1 ms 3416 KB Output is correct
3 Correct 5 ms 3416 KB Output is correct
4 Correct 4 ms 3416 KB Output is correct
5 Correct 5 ms 4048 KB Output is correct
6 Correct 5 ms 3416 KB Output is correct
7 Correct 6 ms 3636 KB Output is correct
8 Correct 4 ms 3416 KB Output is correct
9 Correct 1 ms 3416 KB Output is correct
10 Correct 2 ms 3416 KB Output is correct
11 Correct 2 ms 3416 KB Output is correct
12 Correct 1 ms 3416 KB Output is correct
13 Correct 1 ms 3416 KB Output is correct
14 Correct 2 ms 3416 KB Output is correct
15 Correct 1 ms 3928 KB Output is correct
16 Correct 2 ms 3672 KB Output is correct
17 Correct 2 ms 3672 KB Output is correct
18 Correct 2 ms 3672 KB Output is correct
19 Correct 2 ms 3672 KB Output is correct
20 Correct 2 ms 3416 KB Output is correct
21 Correct 1 ms 3928 KB Output is correct
22 Correct 2 ms 3416 KB Output is correct
23 Correct 1 ms 3928 KB Output is correct
24 Correct 1 ms 3928 KB Output is correct
25 Correct 2 ms 3672 KB Output is correct
26 Correct 1 ms 3928 KB Output is correct
27 Correct 2 ms 3672 KB Output is correct
28 Correct 2 ms 3672 KB Output is correct
29 Correct 6 ms 3416 KB Output is correct
30 Correct 6 ms 3416 KB Output is correct
31 Correct 2 ms 3672 KB Output is correct
32 Correct 2 ms 3672 KB Output is correct
33 Correct 2 ms 3560 KB Output is correct
34 Correct 2 ms 3416 KB Output is correct
35 Correct 2 ms 3416 KB Output is correct
36 Correct 2 ms 3672 KB Output is correct
37 Correct 5 ms 3672 KB Output is correct
38 Correct 6 ms 3672 KB Output is correct
39 Correct 1 ms 3416 KB Output is correct
40 Correct 2 ms 3416 KB Output is correct
41 Correct 2 ms 3588 KB Output is correct
42 Correct 2 ms 3416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 420 ms 6620 KB Output is correct
2 Runtime error 35 ms 17384 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 420 ms 6620 KB Output is correct
2 Runtime error 35 ms 17384 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3416 KB Output is correct
2 Correct 2 ms 3416 KB Output is correct
3 Correct 2 ms 3416 KB Output is correct
4 Correct 1 ms 3416 KB Output is correct
5 Correct 1 ms 3416 KB Output is correct
6 Correct 2 ms 3416 KB Output is correct
7 Correct 1 ms 3928 KB Output is correct
8 Correct 2 ms 3672 KB Output is correct
9 Correct 2 ms 3672 KB Output is correct
10 Correct 2 ms 3672 KB Output is correct
11 Correct 2 ms 3672 KB Output is correct
12 Correct 2 ms 3416 KB Output is correct
13 Correct 420 ms 6620 KB Output is correct
14 Runtime error 35 ms 17384 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3928 KB Output is correct
2 Correct 1 ms 3416 KB Output is correct
3 Correct 5 ms 3416 KB Output is correct
4 Correct 4 ms 3416 KB Output is correct
5 Correct 5 ms 4048 KB Output is correct
6 Correct 5 ms 3416 KB Output is correct
7 Correct 6 ms 3636 KB Output is correct
8 Correct 4 ms 3416 KB Output is correct
9 Correct 1 ms 3416 KB Output is correct
10 Correct 2 ms 3416 KB Output is correct
11 Correct 2 ms 3416 KB Output is correct
12 Correct 1 ms 3416 KB Output is correct
13 Correct 1 ms 3416 KB Output is correct
14 Correct 2 ms 3416 KB Output is correct
15 Correct 1 ms 3928 KB Output is correct
16 Correct 2 ms 3672 KB Output is correct
17 Correct 2 ms 3672 KB Output is correct
18 Correct 2 ms 3672 KB Output is correct
19 Correct 2 ms 3672 KB Output is correct
20 Correct 2 ms 3416 KB Output is correct
21 Correct 1 ms 3928 KB Output is correct
22 Correct 2 ms 3416 KB Output is correct
23 Correct 1 ms 3928 KB Output is correct
24 Correct 1 ms 3928 KB Output is correct
25 Correct 2 ms 3672 KB Output is correct
26 Correct 1 ms 3928 KB Output is correct
27 Correct 2 ms 3672 KB Output is correct
28 Correct 2 ms 3672 KB Output is correct
29 Correct 6 ms 3416 KB Output is correct
30 Correct 6 ms 3416 KB Output is correct
31 Correct 2 ms 3672 KB Output is correct
32 Correct 2 ms 3672 KB Output is correct
33 Correct 2 ms 3560 KB Output is correct
34 Correct 2 ms 3416 KB Output is correct
35 Correct 2 ms 3416 KB Output is correct
36 Correct 2 ms 3672 KB Output is correct
37 Correct 5 ms 3672 KB Output is correct
38 Correct 6 ms 3672 KB Output is correct
39 Correct 1 ms 3416 KB Output is correct
40 Correct 2 ms 3416 KB Output is correct
41 Correct 2 ms 3588 KB Output is correct
42 Correct 2 ms 3416 KB Output is correct
43 Correct 739 ms 4180 KB Output is correct
44 Correct 1030 ms 3672 KB Output is correct
45 Correct 1121 ms 3672 KB Output is correct
46 Correct 558 ms 4440 KB Output is correct
47 Correct 1482 ms 4440 KB Output is correct
48 Correct 1480 ms 3928 KB Output is correct
49 Correct 1487 ms 3948 KB Output is correct
50 Correct 2969 ms 3928 KB Output is correct
51 Execution timed out 3007 ms 3672 KB Time limit exceeded
52 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3928 KB Output is correct
2 Correct 1 ms 3416 KB Output is correct
3 Correct 5 ms 3416 KB Output is correct
4 Correct 4 ms 3416 KB Output is correct
5 Correct 5 ms 4048 KB Output is correct
6 Correct 5 ms 3416 KB Output is correct
7 Correct 6 ms 3636 KB Output is correct
8 Correct 4 ms 3416 KB Output is correct
9 Correct 1 ms 3416 KB Output is correct
10 Correct 2 ms 3416 KB Output is correct
11 Correct 2 ms 3416 KB Output is correct
12 Correct 1 ms 3416 KB Output is correct
13 Correct 1 ms 3416 KB Output is correct
14 Correct 2 ms 3416 KB Output is correct
15 Correct 1 ms 3928 KB Output is correct
16 Correct 2 ms 3672 KB Output is correct
17 Correct 2 ms 3672 KB Output is correct
18 Correct 2 ms 3672 KB Output is correct
19 Correct 2 ms 3672 KB Output is correct
20 Correct 2 ms 3416 KB Output is correct
21 Correct 1 ms 3928 KB Output is correct
22 Correct 2 ms 3416 KB Output is correct
23 Correct 1 ms 3928 KB Output is correct
24 Correct 1 ms 3928 KB Output is correct
25 Correct 2 ms 3672 KB Output is correct
26 Correct 1 ms 3928 KB Output is correct
27 Correct 2 ms 3672 KB Output is correct
28 Correct 2 ms 3672 KB Output is correct
29 Correct 6 ms 3416 KB Output is correct
30 Correct 6 ms 3416 KB Output is correct
31 Correct 2 ms 3672 KB Output is correct
32 Correct 2 ms 3672 KB Output is correct
33 Correct 2 ms 3560 KB Output is correct
34 Correct 2 ms 3416 KB Output is correct
35 Correct 2 ms 3416 KB Output is correct
36 Correct 2 ms 3672 KB Output is correct
37 Correct 5 ms 3672 KB Output is correct
38 Correct 6 ms 3672 KB Output is correct
39 Correct 1 ms 3416 KB Output is correct
40 Correct 2 ms 3416 KB Output is correct
41 Correct 2 ms 3588 KB Output is correct
42 Correct 2 ms 3416 KB Output is correct
43 Correct 420 ms 6620 KB Output is correct
44 Runtime error 35 ms 17384 KB Execution killed with signal 11
45 Halted 0 ms 0 KB -