답안 #974736

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
974736 2024-05-03T17:40:19 Z LucaIlie 디지털 회로 (IOI22_circuit) C++17
2 / 100
3000 ms 7076 KB
#include "circuit.h"
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 2e5;
const int MAX_M = 1e5;
const int MOD = 1e9 + 2022;
int dp1[MAX_N], dpTot[MAX_N];
vector<int> adj[MAX_N];
int n, m;

void dfs( int u ) {
    for ( int v: adj[u] )
        dfs( v );

    dpTot[u] = 1;
    dp1[u] = (u >= n - m ? dp1[u] : 0);
    for ( int v: adj[u] ) {
        dp1[u] = ((long long)dp1[u] * (dpTot[v] - dp1[v] + MOD) % MOD + (long long)(dp1[u] + dpTot[u]) * dp1[v] % MOD) % MOD;
        dpTot[u] = (long long)dpTot[u] * dpTot[v] % MOD;
        //printf( "fii %d %d %d %d\n", u, v, dpTot[u], dp1[u] );
    }
    dpTot[u] = (long long)dpTot[u] * max( 1, (int)adj[u].size() );

    //printf( "%d %d %d\n", u, dpTot[u], dp1[u] );
}

void init( int N, int M, vector<int> P, vector<int> A ) {
    n = N + M, m = M;

    for ( int v = 1; v < n; v++ )
        adj[P[v]].push_back( v );
    for ( int v = 0; v < m; v++ )
        dp1[v + n - m] = A[v];
}

int count_ways( int L, int R ) {
    for ( int i = L; i <= R; i++ )
        dp1[i] = !dp1[i];

    dfs( 0 );

    return dp1[0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4952 KB Output is correct
3 Correct 2 ms 4952 KB Output is correct
4 Correct 1 ms 4952 KB Output is correct
5 Correct 1 ms 4952 KB Output is correct
6 Correct 1 ms 4952 KB Output is correct
7 Correct 1 ms 4952 KB Output is correct
8 Correct 2 ms 4952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4952 KB Output is correct
3 Correct 2 ms 4952 KB Output is correct
4 Correct 2 ms 4952 KB Output is correct
5 Correct 1 ms 4952 KB Output is correct
6 Incorrect 2 ms 4952 KB 1st lines differ - on the 1st token, expected: '706880838', found: '-171188108'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4952 KB Output is correct
3 Correct 2 ms 4952 KB Output is correct
4 Correct 1 ms 4952 KB Output is correct
5 Correct 1 ms 4952 KB Output is correct
6 Correct 1 ms 4952 KB Output is correct
7 Correct 1 ms 4952 KB Output is correct
8 Correct 2 ms 4952 KB Output is correct
9 Correct 1 ms 4952 KB Output is correct
10 Correct 1 ms 4952 KB Output is correct
11 Correct 2 ms 4952 KB Output is correct
12 Correct 2 ms 4952 KB Output is correct
13 Correct 1 ms 4952 KB Output is correct
14 Incorrect 2 ms 4952 KB 1st lines differ - on the 1st token, expected: '706880838', found: '-171188108'
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3067 ms 7076 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3067 ms 7076 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4952 KB Output is correct
3 Correct 2 ms 4952 KB Output is correct
4 Correct 2 ms 4952 KB Output is correct
5 Correct 1 ms 4952 KB Output is correct
6 Incorrect 2 ms 4952 KB 1st lines differ - on the 1st token, expected: '706880838', found: '-171188108'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4952 KB Output is correct
3 Correct 2 ms 4952 KB Output is correct
4 Correct 1 ms 4952 KB Output is correct
5 Correct 1 ms 4952 KB Output is correct
6 Correct 1 ms 4952 KB Output is correct
7 Correct 1 ms 4952 KB Output is correct
8 Correct 2 ms 4952 KB Output is correct
9 Correct 1 ms 4952 KB Output is correct
10 Correct 1 ms 4952 KB Output is correct
11 Correct 2 ms 4952 KB Output is correct
12 Correct 2 ms 4952 KB Output is correct
13 Correct 1 ms 4952 KB Output is correct
14 Incorrect 2 ms 4952 KB 1st lines differ - on the 1st token, expected: '706880838', found: '-171188108'
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4952 KB Output is correct
3 Correct 2 ms 4952 KB Output is correct
4 Correct 1 ms 4952 KB Output is correct
5 Correct 1 ms 4952 KB Output is correct
6 Correct 1 ms 4952 KB Output is correct
7 Correct 1 ms 4952 KB Output is correct
8 Correct 2 ms 4952 KB Output is correct
9 Correct 1 ms 4952 KB Output is correct
10 Correct 1 ms 4952 KB Output is correct
11 Correct 2 ms 4952 KB Output is correct
12 Correct 2 ms 4952 KB Output is correct
13 Correct 1 ms 4952 KB Output is correct
14 Incorrect 2 ms 4952 KB 1st lines differ - on the 1st token, expected: '706880838', found: '-171188108'
15 Halted 0 ms 0 KB -