Submission #860686

# Submission time Handle Problem Language Result Execution time Memory
860686 2023-10-13T17:33:05 Z Ludissey Digital Circuit (IOI22_circuit) C++17
0 / 100
3000 ms 3900 KB
#include "circuit.h"

#include <bits/stdc++.h>

using namespace std;
 
int N,M;
vector<vector<int>> tree;
vector<int> state;
vector<int> poss;

int dfs(int i){
  if(tree[i][0]>=N) {
    return state[tree[i][0]]+state[tree[i][1]];
  }
  int l=dfs(tree[i][0]),r=dfs(tree[i][1]);

  int lv=poss[tree[i][0]], rv=poss[tree[i][1]];
  poss[i]=(2*lv*rv)+(lv*(2-rv))+rv*(2-lv);
  return max(l,1)+max(r,1);
}

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);
  return poss[0];
}

Compilation message

circuit.cpp: In function 'int count_ways(int, int)':
circuit.cpp:33:7: warning: unused variable 'd' [-Wunused-variable]
   33 |   int d=dfs(0);
      |       ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3083 ms 3900 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3083 ms 3900 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -