Submission #869712

# Submission time Handle Problem Language Result Execution time Memory
869712 2023-11-05T11:54:30 Z Ludissey Digital Circuit (IOI22_circuit) C++17
0 / 100
3000 ms 2097152 KB
#include "circuit.h"

#include <bits/stdc++.h>

using namespace std;
 
int N,M;
const int MOD=1e9+2022;
vector<vector<int>> tree;
vector<int> state;
vector<int> depth;
vector<int> poss;

int PowMod(int x, int e)
{
  int res;
  if (e == 0) res = 1;
  else if (e == 1) res = x;
  else {
    res = PowMod(x, e / 2);
    res = res * res % MOD;
    if (e % 2)
  
      res = res * x % MOD;
  }
  return res;
}

int dfs(int i, int on){
  if(i>=N){
    if(on) return state[i];
    else return 1-state[i];
  }
  int lo=dfs(tree[i][0],true), lf=dfs(tree[i][0],false);
  int ro=dfs(tree[i][1],true), rf=dfs(tree[i][1],false);
  int general=(lo*rf)+(ro*lf);
  if(on) return general+(lo*ro*2);
  return general+(2*lf*rf);
}

void init(int n, int m, std::vector<int> P, std::vector<int> A) {
  N=n; M=m;
  tree.resize(N+M); state.resize(N+M);
  for (int i = 1; i < N+M; i++) tree[P[i]].push_back(i);
  for (int i = N; i < N+M; i++) state[i] = A[i-N];
}

int count_ways(int L, int R) {
  poss.clear(); poss.resize(N+M,0);
  for (int i = L; i <= R; i++) state[i] = 1-state[i];
  int d=dfs(0,true);
  return d;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 1837 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '52130940', found: '0'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 1837 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3006 ms 3924 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3006 ms 3924 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '52130940', found: '0'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 1837 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 1837 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -