답안 #1068953

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1068953 2024-08-21T13:44:02 Z beaconmc 디지털 회로 (IOI22_circuit) C++17
22 / 100
3000 ms 13828 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 = 200005;

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 3 ms 7512 KB Output is correct
2 Correct 3 ms 6488 KB Output is correct
3 Correct 6 ms 6644 KB Output is correct
4 Correct 6 ms 6744 KB Output is correct
5 Correct 7 ms 6752 KB Output is correct
6 Correct 6 ms 7772 KB Output is correct
7 Correct 7 ms 6744 KB Output is correct
8 Correct 5 ms 6744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 6488 KB Output is correct
2 Correct 3 ms 6744 KB Output is correct
3 Correct 3 ms 6744 KB Output is correct
4 Correct 3 ms 6744 KB Output is correct
5 Correct 5 ms 6656 KB Output is correct
6 Correct 4 ms 6744 KB Output is correct
7 Correct 3 ms 7768 KB Output is correct
8 Correct 3 ms 6744 KB Output is correct
9 Correct 3 ms 7764 KB Output is correct
10 Correct 3 ms 6744 KB Output is correct
11 Correct 3 ms 6744 KB Output is correct
12 Correct 3 ms 6744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 7512 KB Output is correct
2 Correct 3 ms 6488 KB Output is correct
3 Correct 6 ms 6644 KB Output is correct
4 Correct 6 ms 6744 KB Output is correct
5 Correct 7 ms 6752 KB Output is correct
6 Correct 6 ms 7772 KB Output is correct
7 Correct 7 ms 6744 KB Output is correct
8 Correct 5 ms 6744 KB Output is correct
9 Correct 3 ms 6488 KB Output is correct
10 Correct 3 ms 6744 KB Output is correct
11 Correct 3 ms 6744 KB Output is correct
12 Correct 3 ms 6744 KB Output is correct
13 Correct 5 ms 6656 KB Output is correct
14 Correct 4 ms 6744 KB Output is correct
15 Correct 3 ms 7768 KB Output is correct
16 Correct 3 ms 6744 KB Output is correct
17 Correct 3 ms 7764 KB Output is correct
18 Correct 3 ms 6744 KB Output is correct
19 Correct 3 ms 6744 KB Output is correct
20 Correct 3 ms 6744 KB Output is correct
21 Correct 3 ms 7768 KB Output is correct
22 Correct 3 ms 7592 KB Output is correct
23 Correct 3 ms 6744 KB Output is correct
24 Correct 3 ms 6744 KB Output is correct
25 Correct 5 ms 6744 KB Output is correct
26 Correct 3 ms 6744 KB Output is correct
27 Correct 4 ms 6744 KB Output is correct
28 Correct 4 ms 6744 KB Output is correct
29 Correct 7 ms 6744 KB Output is correct
30 Correct 7 ms 6772 KB Output is correct
31 Correct 3 ms 6744 KB Output is correct
32 Correct 3 ms 6744 KB Output is correct
33 Correct 3 ms 7764 KB Output is correct
34 Correct 3 ms 7768 KB Output is correct
35 Correct 4 ms 7768 KB Output is correct
36 Correct 3 ms 6744 KB Output is correct
37 Correct 7 ms 6668 KB Output is correct
38 Correct 7 ms 7768 KB Output is correct
39 Correct 3 ms 7768 KB Output is correct
40 Correct 3 ms 7768 KB Output is correct
41 Correct 4 ms 6744 KB Output is correct
42 Correct 3 ms 6744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 497 ms 9560 KB Output is correct
2 Correct 649 ms 12888 KB Output is correct
3 Correct 695 ms 13828 KB Output is correct
4 Correct 629 ms 13652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 497 ms 9560 KB Output is correct
2 Correct 649 ms 12888 KB Output is correct
3 Correct 695 ms 13828 KB Output is correct
4 Correct 629 ms 13652 KB Output is correct
5 Execution timed out 3063 ms 10584 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 6488 KB Output is correct
2 Correct 3 ms 6744 KB Output is correct
3 Correct 3 ms 6744 KB Output is correct
4 Correct 3 ms 6744 KB Output is correct
5 Correct 5 ms 6656 KB Output is correct
6 Correct 4 ms 6744 KB Output is correct
7 Correct 3 ms 7768 KB Output is correct
8 Correct 3 ms 6744 KB Output is correct
9 Correct 3 ms 7764 KB Output is correct
10 Correct 3 ms 6744 KB Output is correct
11 Correct 3 ms 6744 KB Output is correct
12 Correct 3 ms 6744 KB Output is correct
13 Correct 497 ms 9560 KB Output is correct
14 Correct 649 ms 12888 KB Output is correct
15 Correct 695 ms 13828 KB Output is correct
16 Correct 629 ms 13652 KB Output is correct
17 Execution timed out 3063 ms 10584 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 7512 KB Output is correct
2 Correct 3 ms 6488 KB Output is correct
3 Correct 6 ms 6644 KB Output is correct
4 Correct 6 ms 6744 KB Output is correct
5 Correct 7 ms 6752 KB Output is correct
6 Correct 6 ms 7772 KB Output is correct
7 Correct 7 ms 6744 KB Output is correct
8 Correct 5 ms 6744 KB Output is correct
9 Correct 3 ms 6488 KB Output is correct
10 Correct 3 ms 6744 KB Output is correct
11 Correct 3 ms 6744 KB Output is correct
12 Correct 3 ms 6744 KB Output is correct
13 Correct 5 ms 6656 KB Output is correct
14 Correct 4 ms 6744 KB Output is correct
15 Correct 3 ms 7768 KB Output is correct
16 Correct 3 ms 6744 KB Output is correct
17 Correct 3 ms 7764 KB Output is correct
18 Correct 3 ms 6744 KB Output is correct
19 Correct 3 ms 6744 KB Output is correct
20 Correct 3 ms 6744 KB Output is correct
21 Correct 3 ms 7768 KB Output is correct
22 Correct 3 ms 7592 KB Output is correct
23 Correct 3 ms 6744 KB Output is correct
24 Correct 3 ms 6744 KB Output is correct
25 Correct 5 ms 6744 KB Output is correct
26 Correct 3 ms 6744 KB Output is correct
27 Correct 4 ms 6744 KB Output is correct
28 Correct 4 ms 6744 KB Output is correct
29 Correct 7 ms 6744 KB Output is correct
30 Correct 7 ms 6772 KB Output is correct
31 Correct 3 ms 6744 KB Output is correct
32 Correct 3 ms 6744 KB Output is correct
33 Correct 3 ms 7764 KB Output is correct
34 Correct 3 ms 7768 KB Output is correct
35 Correct 4 ms 7768 KB Output is correct
36 Correct 3 ms 6744 KB Output is correct
37 Correct 7 ms 6668 KB Output is correct
38 Correct 7 ms 7768 KB Output is correct
39 Correct 3 ms 7768 KB Output is correct
40 Correct 3 ms 7768 KB Output is correct
41 Correct 4 ms 6744 KB Output is correct
42 Correct 3 ms 6744 KB Output is correct
43 Correct 800 ms 7768 KB Output is correct
44 Correct 1016 ms 8024 KB Output is correct
45 Correct 1090 ms 8024 KB Output is correct
46 Correct 655 ms 7000 KB Output is correct
47 Correct 1505 ms 7000 KB Output is correct
48 Correct 1482 ms 7000 KB Output is correct
49 Correct 1471 ms 7000 KB Output is correct
50 Correct 2946 ms 8024 KB Output is correct
51 Execution timed out 3020 ms 7988 KB Time limit exceeded
52 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 7512 KB Output is correct
2 Correct 3 ms 6488 KB Output is correct
3 Correct 6 ms 6644 KB Output is correct
4 Correct 6 ms 6744 KB Output is correct
5 Correct 7 ms 6752 KB Output is correct
6 Correct 6 ms 7772 KB Output is correct
7 Correct 7 ms 6744 KB Output is correct
8 Correct 5 ms 6744 KB Output is correct
9 Correct 3 ms 6488 KB Output is correct
10 Correct 3 ms 6744 KB Output is correct
11 Correct 3 ms 6744 KB Output is correct
12 Correct 3 ms 6744 KB Output is correct
13 Correct 5 ms 6656 KB Output is correct
14 Correct 4 ms 6744 KB Output is correct
15 Correct 3 ms 7768 KB Output is correct
16 Correct 3 ms 6744 KB Output is correct
17 Correct 3 ms 7764 KB Output is correct
18 Correct 3 ms 6744 KB Output is correct
19 Correct 3 ms 6744 KB Output is correct
20 Correct 3 ms 6744 KB Output is correct
21 Correct 3 ms 7768 KB Output is correct
22 Correct 3 ms 7592 KB Output is correct
23 Correct 3 ms 6744 KB Output is correct
24 Correct 3 ms 6744 KB Output is correct
25 Correct 5 ms 6744 KB Output is correct
26 Correct 3 ms 6744 KB Output is correct
27 Correct 4 ms 6744 KB Output is correct
28 Correct 4 ms 6744 KB Output is correct
29 Correct 7 ms 6744 KB Output is correct
30 Correct 7 ms 6772 KB Output is correct
31 Correct 3 ms 6744 KB Output is correct
32 Correct 3 ms 6744 KB Output is correct
33 Correct 3 ms 7764 KB Output is correct
34 Correct 3 ms 7768 KB Output is correct
35 Correct 4 ms 7768 KB Output is correct
36 Correct 3 ms 6744 KB Output is correct
37 Correct 7 ms 6668 KB Output is correct
38 Correct 7 ms 7768 KB Output is correct
39 Correct 3 ms 7768 KB Output is correct
40 Correct 3 ms 7768 KB Output is correct
41 Correct 4 ms 6744 KB Output is correct
42 Correct 3 ms 6744 KB Output is correct
43 Correct 497 ms 9560 KB Output is correct
44 Correct 649 ms 12888 KB Output is correct
45 Correct 695 ms 13828 KB Output is correct
46 Correct 629 ms 13652 KB Output is correct
47 Execution timed out 3063 ms 10584 KB Time limit exceeded
48 Halted 0 ms 0 KB -