답안 #826154

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
826154 2023-08-15T10:46:15 Z PixelCat 디지털 회로 (IOI22_circuit) C++17
4 / 100
794 ms 13204 KB
#include "circuit.h"

#ifdef NYAOWO
#include "stub.cpp"
#endif

#include <bits/stdc++.h>
#define For(i, a, b) for(int i = a; i <= b; i++)
#define Forr(i, a, b) for(int i = a; i >= b; i--)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) ((int)x.size())
#define eb emplace_back
#define int LL
using namespace std;
using i32 = int32_t;
using LL = long long;
using pii = pair<int, int>;

const int MAXN = 200'000;
const int MOD = 1'000'002'022;

int n, m;
vector<int> adj[MAXN + 10];
int p[MAXN + 10];
int a[MAXN + 10];

int s[MAXN + 10];
int xs[MAXN + 10];

void dfs(int x) {
    if(x >= n) {
        s[x] = 1;
        return;
    }
    xs[x] = 0;
    s[x] = sz(adj[x]);
    for(auto &i:adj[x]) {
        dfs(i);
        s[x] = s[x] * s[i] % MOD;
        xs[x] ^= s[i];
    }
}

int ss[MAXN + 10];
void dfs2(int x, int owo) {
    if(x >= n) {
        ss[x] = owo;
        return;
    }
    for(auto &i:adj[x]) {
        dfs2(i, (owo * (xs[x] ^ s[i])) % MOD);
    }
}

int dp[MAXN + 10];
void update(int x) {
    if(x >= n) {
        dp[x] = a[x];
        return;
    }
    int l = adj[x][0];
    int r = adj[x][1];
    dp[x] = (s[l] * dp[r] + s[r] * dp[l]) % MOD;
}

void update_leaf(int x) {
    update(x);
    while(x != 0) {
        x = p[x];
        update(x);
    }
}

void init(i32 N, i32 M, std::vector<i32> P, std::vector<i32> A) {
    n = N; m = M;
    p[0] = -1;
    For(i, 1, n + m - 1) {
        adj[P[i]].eb(i);
        p[i] = P[i];
    }
    dfs(0);
    dfs2(0, 1);
    For(i, 0, m - 1) {
        a[n + i] = A[i];
        update_leaf(n + i);
    }
}

i32 count_ways(i32 L, i32 R) {
    a[L] = 1 - a[L];
    update_leaf(L);
    return dp[0];
}

/*

3 4 3
-1 0 1 2 1 1 0
1 0 1 0
3 4
4 5
3 6

2
0
6

*/
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 4944 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 4944 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 4944 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 468 ms 9040 KB Output is correct
2 Correct 794 ms 13128 KB Output is correct
3 Correct 690 ms 13204 KB Output is correct
4 Correct 782 ms 13164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 468 ms 9040 KB Output is correct
2 Correct 794 ms 13128 KB Output is correct
3 Correct 690 ms 13204 KB Output is correct
4 Correct 782 ms 13164 KB Output is correct
5 Incorrect 734 ms 9040 KB 1st lines differ - on the 1st token, expected: '105182172', found: '2777846'
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 4944 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 4944 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 4944 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -