Submission #1108330

#TimeUsernameProblemLanguageResultExecution timeMemory
1108330LucaLucaMDigital Circuit (IOI22_circuit)C++17
0 / 100
3065 ms1616 KiB
#ifdef LOCAL #include "grader.h" #else #include "circuit.h" #endif #include <vector> using ll = long long; const int NMAX = 2e5; const int mod = 1e9 + 2022; int depth[NMAX]; int p2[NMAX]; std::vector<int> a; int n, m; void init(int N, int M, std::vector<int> parent, std::vector<int> A) { n = N; m = M; a = A; p2[0] = 1; for (int i = 1; i <= n + m; i++) { p2[i] = p2[i - 1] * 2 % mod; } for (int i = 1; i < n + m; i++) { depth[i] = 1 + depth[parent[i]]; } } int count_ways(int L, int R) { L -= n, R -= n; for (int i = L; i <= R; i++) { a[i] ^= 1; } ll answer = 0; for (int i = 0; i < m; i++) { if (a[i]) { answer += p2[depth[i + n]]; } } return answer % mod; }
#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...