Submission #643488

#TimeUsernameProblemLanguageResultExecution timeMemory
643488VanillaDigital Circuit (IOI22_circuit)C++17
0 / 100
15 ms1964 KiB
#include <bits/stdc++.h> #include "circuit.h" typedef long long int64; using namespace std; const int64 mod = 1000002022; const int maxn = 2e3 + 2; // vector <int> ad [maxn]; int64 dp[maxn][2]; int64 lazy[maxn]; int n,m; void init(int N, int M, vector<int> P, vector<int> A) { n = N, m = M; for (int i = 0; i < M; i++){ dp[N+i][A[i]] = 1; } } void push (int x, int nl, int nr) { if (!lazy[x]) return; swap(dp[nl][0], dp[nl][1]); swap(dp[nr][0], dp[nr][1]); lazy[nl] = !lazy[nl]; lazy[nr] = !lazy[nr]; lazy[x] = 0; } void upd (int x, int l, int r, int il, int ir) { int nl = x * 2 + 1, nr = x * 2 + 2; if (il <= l && r <= ir) { lazy[x] = !lazy[x]; swap(dp[x][0], dp[x][1]); return; } if (l > ir || r < il) return; push(x, nl, nr); int mid = (l + r) / 2; upd(nl, l, mid, il, ir); upd(nr, mid + 1, r, il, ir); dp[x][0] = ((dp[nl][0] * dp[nr][0] * 2 % mod) + (dp[nl][0] * dp[nr][1] % mod) + (dp[nl][1] * dp[nr][0] % mod)) % mod; dp[x][1] = ((dp[nl][1] * dp[nr][1] * 2 % mod) + (dp[nl][0] * dp[nr][1] % mod) + (dp[nl][1] * dp[nr][0] % mod)) % mod; } int count_ways(int L, int R) { // for (int i = L; i <= R; i++){ // swap(dp[i][0], dp[i][1]); // } upd(0, n, n + m - 1, L, R); return dp[0][1]; }
#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...