답안 #627371

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
627371 2022-08-12T13:57:27 Z Elegia 디지털 회로 (IOI22_circuit) C++17
2 / 100
3000 ms 3664 KB
#include "circuit.h"

#include <algorithm>
#include <iostream>
#include <vector>

using ull = unsigned long long;

const int MOD = 1000002022;

int N, M;
std::vector<int> P, A, prod;
std::vector<std::vector<int>> ch;

void init(int _N, int _M, std::vector<int> _P, std::vector<int> _A) {
  N = _N; M = _M;
  P = _P;
  prod.resize(N + M);
  std::fill(prod.begin() + N, prod.end(), 1);
  for (int i = 1; i != N + M; ++i) ++prod[P[i]];
  for (int i = N - 1; i; --i) prod[P[i]] *= prod[i];
  A.resize(N + M);
  std::copy(_A.begin(), _A.end(), A.begin() + N);
  ch.resize(N);
  for (int i = 1; i != N + M; ++i) ch[P[i]].push_back(i);
}

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

  for (int i = N - 1; i >= 0; --i) {
    int f0 = 1, f1 = 0;
    for (int j : ch[i]) {
      f1 = (f0 * (ull)A[j] + f1 * (ull)prod[j]) % MOD;
      f0 = f0 * (ull)prod[j] % MOD;
    }
    A[i] = f1;
  }

  return A[0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '52130940', found: '0'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '52130940', found: '0'
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3022 ms 3664 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3022 ms 3664 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '52130940', found: '0'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '52130940', found: '0'
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '52130940', found: '0'
11 Halted 0 ms 0 KB -