답안 #914504

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
914504 2024-01-22T09:33:34 Z cig32 디지털 회로 (IOI22_circuit) C++17
2 / 100
397 ms 13156 KB
#include "circuit.h"
#include "bits/stdc++.h"
using namespace std;
#define int long long

#include <vector>

const int MAXN = 2e5 + 12;
const int MOD = 1e9 + 2022;
int n, m;
vector<int> adj[MAXN];
int contrib[MAXN];
int ans;
int a[MAXN];
int lazy[MAXN];
int Y[MAXN];
void calc_y(int node) {
  Y[node] = adj[node].size();
  Y[node] = max(1ll, Y[node]);
  for(int x: adj[node]) {
    calc_y(x);
    Y[node] *= Y[x];
    Y[node] %= MOD;
  }
}
void propagate(int node) {
  for(int x: adj[node]) {
    lazy[x] *= lazy[node];
    lazy[x] %= MOD;
    propagate(x);
  }
}
void init(int32_t N, int32_t M, std::vector<int32_t> P, std::vector<int32_t> A) {
  for(int i=0; i<M; i++) contrib[i] = 1;
  for(int i=1; i<N+M; i++) adj[P[i]].push_back(i);
  for(int i=0; i<M; i++) a[i] = A[i];
  n = N;
  m = M;
  ans = 0;
  calc_y(0);
  for(int i=0; i<N+M; i++) lazy[i] = 1;
  for(int i=0; i<N; i++) {
    for(int x: adj[i]) {
      for(int y: adj[i]) {
        if(x != y) {
          lazy[y] *= Y[x];
          lazy[y] %= MOD;
        }
      }
    }
  }
  propagate(0);
  for(int i=0; i<N+M; i++) {
    contrib[i] = lazy[i];
  }
  for(int i=0; i<M; i++) {
    if(a[i]) ans = (ans + contrib[i]) % MOD;
  }
}

int32_t count_ways(int32_t L, int32_t R) {
  L -= n;
  R -= n;
  for(int i=L; i<=R; i++) {
    if(a[i] == 1) {
      a[i] = 0;
      ans = (ans + MOD - contrib[n + i]) % MOD;
    }
    else {
      a[i] = 1;
      ans = (ans + contrib[n + i]) % MOD;
    }
  }
  return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 11092 KB Output is correct
2 Correct 3 ms 11096 KB Output is correct
3 Correct 5 ms 11096 KB Output is correct
4 Correct 5 ms 11092 KB Output is correct
5 Correct 5 ms 11096 KB Output is correct
6 Correct 4 ms 11096 KB Output is correct
7 Correct 4 ms 11256 KB Output is correct
8 Correct 4 ms 11096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 11096 KB Output is correct
2 Incorrect 3 ms 11096 KB 1st lines differ - on the 1st token, expected: '52130940', found: '305042130'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 11092 KB Output is correct
2 Correct 3 ms 11096 KB Output is correct
3 Correct 5 ms 11096 KB Output is correct
4 Correct 5 ms 11092 KB Output is correct
5 Correct 5 ms 11096 KB Output is correct
6 Correct 4 ms 11096 KB Output is correct
7 Correct 4 ms 11256 KB Output is correct
8 Correct 4 ms 11096 KB Output is correct
9 Correct 3 ms 11096 KB Output is correct
10 Incorrect 3 ms 11096 KB 1st lines differ - on the 1st token, expected: '52130940', found: '305042130'
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 397 ms 13156 KB 1st lines differ - on the 1st token, expected: '431985922', found: '719717540'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 397 ms 13156 KB 1st lines differ - on the 1st token, expected: '431985922', found: '719717540'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 11096 KB Output is correct
2 Incorrect 3 ms 11096 KB 1st lines differ - on the 1st token, expected: '52130940', found: '305042130'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 11092 KB Output is correct
2 Correct 3 ms 11096 KB Output is correct
3 Correct 5 ms 11096 KB Output is correct
4 Correct 5 ms 11092 KB Output is correct
5 Correct 5 ms 11096 KB Output is correct
6 Correct 4 ms 11096 KB Output is correct
7 Correct 4 ms 11256 KB Output is correct
8 Correct 4 ms 11096 KB Output is correct
9 Correct 3 ms 11096 KB Output is correct
10 Incorrect 3 ms 11096 KB 1st lines differ - on the 1st token, expected: '52130940', found: '305042130'
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 11092 KB Output is correct
2 Correct 3 ms 11096 KB Output is correct
3 Correct 5 ms 11096 KB Output is correct
4 Correct 5 ms 11092 KB Output is correct
5 Correct 5 ms 11096 KB Output is correct
6 Correct 4 ms 11096 KB Output is correct
7 Correct 4 ms 11256 KB Output is correct
8 Correct 4 ms 11096 KB Output is correct
9 Correct 3 ms 11096 KB Output is correct
10 Incorrect 3 ms 11096 KB 1st lines differ - on the 1st token, expected: '52130940', found: '305042130'
11 Halted 0 ms 0 KB -