Submission #643474

# Submission time Handle Problem Language Result Execution time Memory
643474 2022-09-22T06:20:45 Z Vanilla Digital Circuit (IOI22_circuit) C++17
0 / 100
16 ms 2128 KB
#include <bits/stdc++.h>
#include "circuit.h"
typedef long long int64;
using namespace std;
const int64 mod = 1000002022;
const int maxn = 2e3 + 2;
vector <int> ad [maxn];
int64 dp[maxn][2];
int n,m;

void init(int N, int M, vector<int> P, vector<int> A) {
  n = N, m = M;
  for (int i = 1; i < N + M; i++){
    ad[P[i]].push_back(i);
  }
  for (int i = 0; i < M; i++){
    dp[N+i][A[i]] = 1;
  }
}

void build (int x) {
  if (x > n) return;
  int l = ad[x][0], r = ad[x][1];
  build(l); build(r);
  dp[x][0] = ((dp[l][0] * dp[r][0] * 2 % mod) + (dp[l][0] * dp[r][1] % mod) + (dp[l][1] * dp[r][0] % mod)) % mod;
  dp[x][1] = ((dp[l][1] * dp[r][1] * 2 % mod) + (dp[l][0] * dp[r][1] % mod) + (dp[l][1] * dp[r][0] % mod)) % mod;
}

int count_ways(int L, int R) {
  for (int i = L; i <= R; i++){
    swap(dp[n+i][0], dp[n+i][1]);
  }
  build(0);
  return dp[0][1];
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 16 ms 2128 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 16 ms 2128 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -