답안 #702659

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
702659 2023-02-24T17:46:40 Z boris_mihov 디지털 회로 (IOI22_circuit) C++17
18 / 100
3000 ms 7948 KB
#include "circuit.h"
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

typedef long long llong;
const int MAXN = 200000 + 10;
const int MOD = 1000002022;
const int INF = 1e9;

int n, m;
llong w[MAXN];
llong b[MAXN];
llong pw[MAXN];
std::vector <int> g[MAXN];
void init(int N, int M, std::vector <int> P, std::vector <int> A) 
{
    n = N;
    m = M;
    for (int i = 1 ; i < n + m ; ++i)
    {
        g[P[i] + 1].push_back(i + 1);
    }

    for (int i = n + 1 ; i <= n + m ; ++i)
    {
        if (A[i - n - 1] == 0)
        {
            w[i] = 1;
            b[i] = 0;
        } else
        {
            b[i] = 1;
            w[i] = 0;
        }
    }
}

void dfs(int node)
{
    if (g[node].empty())
    {
        pw[node] = 1;
        return;
    }

    b[node] = 0;
    llong sum = 1;
    pw[node] = g[node].size();
    for (const int &i : g[node])
    {
        dfs(i);
        b[node] = (w[i] * b[node] + b[i] * (b[node] + sum)) % MOD;
        sum = (w[i] + b[i]) * sum; sum %= MOD;
        pw[node] *= pw[i];
        pw[node] %= MOD;
    }

    w[node] = pw[node] - b[node];
    if (w[node] < 0) w[node] += MOD;
}

int count_ways(int L, int R) 
{
    L++; R++;
    for (int i = L ; i <= R ; ++i)
    {
        std::swap(b[i], w[i]);
    }

    dfs(1);
    return b[1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4944 KB Output is correct
2 Correct 3 ms 4944 KB Output is correct
3 Correct 2 ms 4944 KB Output is correct
4 Correct 3 ms 4944 KB Output is correct
5 Correct 3 ms 4944 KB Output is correct
6 Correct 4 ms 4944 KB Output is correct
7 Correct 3 ms 4944 KB Output is correct
8 Correct 4 ms 4944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4944 KB Output is correct
2 Correct 3 ms 4968 KB Output is correct
3 Correct 3 ms 4944 KB Output is correct
4 Correct 4 ms 4944 KB Output is correct
5 Correct 3 ms 4944 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 3 ms 5072 KB Output is correct
10 Correct 4 ms 5072 KB Output is correct
11 Correct 5 ms 5072 KB Output is correct
12 Correct 3 ms 5072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4944 KB Output is correct
2 Correct 3 ms 4944 KB Output is correct
3 Correct 2 ms 4944 KB Output is correct
4 Correct 3 ms 4944 KB Output is correct
5 Correct 3 ms 4944 KB Output is correct
6 Correct 4 ms 4944 KB Output is correct
7 Correct 3 ms 4944 KB Output is correct
8 Correct 4 ms 4944 KB Output is correct
9 Correct 2 ms 4944 KB Output is correct
10 Correct 3 ms 4968 KB Output is correct
11 Correct 3 ms 4944 KB Output is correct
12 Correct 4 ms 4944 KB Output is correct
13 Correct 3 ms 4944 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 3 ms 5072 KB Output is correct
18 Correct 4 ms 5072 KB Output is correct
19 Correct 5 ms 5072 KB Output is correct
20 Correct 3 ms 5072 KB Output is correct
21 Correct 3 ms 5072 KB Output is correct
22 Correct 3 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 3 ms 5072 KB Output is correct
26 Correct 3 ms 5072 KB Output is correct
27 Correct 4 ms 5072 KB Output is correct
28 Correct 4 ms 5072 KB Output is correct
29 Correct 3 ms 4944 KB Output is correct
30 Correct 3 ms 4944 KB Output is correct
31 Correct 3 ms 5072 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 4944 KB Output is correct
36 Correct 3 ms 5072 KB Output is correct
37 Correct 3 ms 5072 KB Output is correct
38 Correct 3 ms 5072 KB Output is correct
39 Correct 3 ms 5072 KB Output is correct
40 Correct 3 ms 5072 KB Output is correct
41 Correct 3 ms 5072 KB Output is correct
42 Correct 3 ms 4944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3057 ms 7948 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3057 ms 7948 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4944 KB Output is correct
2 Correct 3 ms 4968 KB Output is correct
3 Correct 3 ms 4944 KB Output is correct
4 Correct 4 ms 4944 KB Output is correct
5 Correct 3 ms 4944 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 3 ms 5072 KB Output is correct
10 Correct 4 ms 5072 KB Output is correct
11 Correct 5 ms 5072 KB Output is correct
12 Correct 3 ms 5072 KB Output is correct
13 Execution timed out 3057 ms 7948 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4944 KB Output is correct
2 Correct 3 ms 4944 KB Output is correct
3 Correct 2 ms 4944 KB Output is correct
4 Correct 3 ms 4944 KB Output is correct
5 Correct 3 ms 4944 KB Output is correct
6 Correct 4 ms 4944 KB Output is correct
7 Correct 3 ms 4944 KB Output is correct
8 Correct 4 ms 4944 KB Output is correct
9 Correct 2 ms 4944 KB Output is correct
10 Correct 3 ms 4968 KB Output is correct
11 Correct 3 ms 4944 KB Output is correct
12 Correct 4 ms 4944 KB Output is correct
13 Correct 3 ms 4944 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 3 ms 5072 KB Output is correct
18 Correct 4 ms 5072 KB Output is correct
19 Correct 5 ms 5072 KB Output is correct
20 Correct 3 ms 5072 KB Output is correct
21 Correct 3 ms 5072 KB Output is correct
22 Correct 3 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 3 ms 5072 KB Output is correct
26 Correct 3 ms 5072 KB Output is correct
27 Correct 4 ms 5072 KB Output is correct
28 Correct 4 ms 5072 KB Output is correct
29 Correct 3 ms 4944 KB Output is correct
30 Correct 3 ms 4944 KB Output is correct
31 Correct 3 ms 5072 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 4944 KB Output is correct
36 Correct 3 ms 5072 KB Output is correct
37 Correct 3 ms 5072 KB Output is correct
38 Correct 3 ms 5072 KB Output is correct
39 Correct 3 ms 5072 KB Output is correct
40 Correct 3 ms 5072 KB Output is correct
41 Correct 3 ms 5072 KB Output is correct
42 Correct 3 ms 4944 KB Output is correct
43 Execution timed out 3059 ms 5200 KB Time limit exceeded
44 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4944 KB Output is correct
2 Correct 3 ms 4944 KB Output is correct
3 Correct 2 ms 4944 KB Output is correct
4 Correct 3 ms 4944 KB Output is correct
5 Correct 3 ms 4944 KB Output is correct
6 Correct 4 ms 4944 KB Output is correct
7 Correct 3 ms 4944 KB Output is correct
8 Correct 4 ms 4944 KB Output is correct
9 Correct 2 ms 4944 KB Output is correct
10 Correct 3 ms 4968 KB Output is correct
11 Correct 3 ms 4944 KB Output is correct
12 Correct 4 ms 4944 KB Output is correct
13 Correct 3 ms 4944 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 3 ms 5072 KB Output is correct
18 Correct 4 ms 5072 KB Output is correct
19 Correct 5 ms 5072 KB Output is correct
20 Correct 3 ms 5072 KB Output is correct
21 Correct 3 ms 5072 KB Output is correct
22 Correct 3 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 3 ms 5072 KB Output is correct
26 Correct 3 ms 5072 KB Output is correct
27 Correct 4 ms 5072 KB Output is correct
28 Correct 4 ms 5072 KB Output is correct
29 Correct 3 ms 4944 KB Output is correct
30 Correct 3 ms 4944 KB Output is correct
31 Correct 3 ms 5072 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 4944 KB Output is correct
36 Correct 3 ms 5072 KB Output is correct
37 Correct 3 ms 5072 KB Output is correct
38 Correct 3 ms 5072 KB Output is correct
39 Correct 3 ms 5072 KB Output is correct
40 Correct 3 ms 5072 KB Output is correct
41 Correct 3 ms 5072 KB Output is correct
42 Correct 3 ms 4944 KB Output is correct
43 Execution timed out 3057 ms 7948 KB Time limit exceeded
44 Halted 0 ms 0 KB -