답안 #643476

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
643476 2022-09-22T06:26:44 Z Vanilla 디지털 회로 (IOI22_circuit) C++17
7 / 100
1601 ms 2097152 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[i][0], dp[i][1]);
  }
  build(0);
  return dp[0][1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Runtime error 1601 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 356 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Runtime error 1601 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 10 ms 2128 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 10 ms 2128 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 356 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Runtime error 10 ms 2128 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Runtime error 1601 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Runtime error 1601 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -