제출 #869712

#제출 시각아이디문제언어결과실행 시간메모리
869712Ludissey디지털 회로 (IOI22_circuit)C++17
0 / 100
3006 ms2097152 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...