# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
860680 | Ludissey | Digital Circuit (IOI22_circuit) | C++17 | 13 ms | 3980 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 poss[i]=state[tree[i][0]]+state[tree[i][1]];
cout << i << "-i " << poss[i]<<"-possib \n";
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)+(l*(2-r))+r*(2-l);
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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |