# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
870407 | Nonoze | Digital Circuit (IOI22_circuit) | C++17 | 0 ms | 0 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 "stub.cpp"
#include <bits/stdc++.h>
using namespace std;
const long long MOD= 1000002022;
vector<int> a;
vector<int> adj[100005];
int n, m;
pair<long long, long long> dfs(int s) {
if (s>=n) {
return {a[s-n], a[s-n]^1};
}
long long comp=0;
vector<long long> dp(adj[s].size()+1, 0);
dp[0]=1;
for (auto u: adj[s]) {
auto act=dfs(u);
for (int i=dp.size()-1; i>=0; i--) {
dp[i]*=act.second;
if (i>0) {
dp[i]+=dp[i-1]*act.first;
}
dp[i]%=MOD;
}
}
for (int i=1; i<(int)dp.size()-1; i++) {