Submission #912626

#TimeUsernameProblemLanguageResultExecution timeMemory
912626biankDigital Circuit (IOI22_circuit)C++17
7 / 100
10 ms2540 KiB
#include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef long long ll; typedef pair<ll,ll> pll; #define ALL(x) x.begin(),x.end() #define SIZE(x) (int)x.size() #define forsn(i,s,n) for(int i=int(s);i<int(n);i++) #define forn(i,n) for(int i=0;i<int(n);i++) #define fst first #define snd second #define pb push_back const int MAXN = 2000; const int MOD = 1e9+2022; vi s, adj[MAXN]; int n, m; void init(int N, int M, vi P, vi A) { s=A, n=N, m=M; forsn(i,1,n+m) adj[P[i]].pb(i); } pll dfs(int u) { if(SIZE(adj[u])==0) { return {!s[u-n], s[u-n]}; } pll l = dfs(adj[u][0]); forsn(i,1,SIZE(adj[u])) { pll r = dfs(adj[u][i]); ll ways = (l.fst * r.snd % MOD + l.snd * r.fst % MOD) % MOD; l = {(ways + 2LL * l.fst * r.fst % MOD) % MOD, (ways + 2LL * l.snd * r.snd % MOD) % MOD}; } return l; } int count_ways(int L, int R) { forsn(i,L,R+1) { s[i-n]^=1; } return int(dfs(0).snd); }
#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...