답안 #1038542

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1038542 2024-07-29T23:00:35 Z HappyCapybara 디지털 회로 (IOI22_circuit) C++17
0 / 100
3000 ms 2097152 KB
#include "circuit.h"
#include<bits/stdc++.h>
using namespace std;

#define ll long long

int y = 1000002022;
int n, m;
vector<int> p, a;
vector<vector<int>> g;
vector<ll> cw, aw;

ll fcw(int x){
  if (x >= n) return cw[x] = a[x-n];
  //cout << x << " " << g[x].size() << "\n";
  //cout << fcw(g[x][0]) << " " << fcw(g[x][1]) << " " << aw[g[x][0]] << " " << aw[g[x][1]] << "\n";
  return cw[x] = (((fcw(g[x][0])*aw[g[x][1]]) % y) + ((fcw(g[x][1])*aw[g[x][0]] % y)) % y);
}

ll faw(int x){
  //cout << x << "\n";
  if (x >= n) return aw[x] = 1;
  ll res = g[x].size();
  for (int next : g[x]) res = (res*faw(next)) % y;
  return aw[x] = res;
}

void init(int N, int M, vector<int> P, vector<int> A){
  n = N;
  m = M;
  p = P;
  a = A;
  g.resize(N);
  for (int i=1; i<N+M; i++) g[p[i]].push_back(i);
  cw.resize(N+M);
  aw.resize(N+M);
  faw(0);
}

int count_ways(int L, int R){
  for (int i=L; i<=R; i++) a[i-n] = 1-a[i-n];
  /*for (int i=0; i<m; i++) cout << a[i] << " ";
  cout << "\n";*/
  /*fcw(0);
  for (int i=0; i<n+m; i++) cout << aw[i] << " ";
  cout << "\n";
  for (int i=0; i<n+m; i++) cout << cw[i] << " ";
  cout << "\n";
  return cw[0];*/
  return fcw(0);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Runtime error 1344 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '52130940', found: '1052132962'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Runtime error 1344 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3096 ms 4184 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3096 ms 4184 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '52130940', found: '1052132962'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Runtime error 1344 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Runtime error 1344 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -