Submission #1063201

#TimeUsernameProblemLanguageResultExecution timeMemory
1063201jer033Digital Circuit (IOI22_circuit)C++17
46 / 100
3078 ms267600 KiB
#include "circuit.h" #include <vector> #include <bits/stdc++.h> using namespace std; using ll = long long; const ll MOD = 1'000'002'022; int n, m; vector<ll> storage; vector<int> a; void init(int N, int M, std::vector<int> P, std::vector<int> A) { n = N; m = M; vector<ll> degrees(N, 0); for (int i=1; i<(N+M); i++) degrees[P[i]]++; vector<vector<bool>> ancestor(N+M, vector<bool> (N, 0)); for (int i=1; i<(N+M); i++) { int par = P[i]; for (int j=0; j<N; j++) ancestor[i][j] = ancestor[par][j]; ancestor[i][par] = 1; } for (int i=N; i<(N+M); i++) { a.push_back(A[i-N]); ll ans = 1; for (int j = 0; j<N; j++) if (ancestor[i][j] == 0) ans = (ans*degrees[j])%MOD; storage.push_back(ans); } } int count_ways(int L, int R) { L -= n; R -= n; for (int i=L; i<=R; i++) a[i] = 1-a[i]; ll total = 0; for (int i=0; i<m; i++) { if (a[i]==1) total = total+storage[i]; } ll fa = total%MOD; int ffa = fa; return ffa; }
#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...