# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1028305 | 2024-07-19T16:13:04 Z | 42kangaroo | Digital Circuit (IOI22_circuit) | C++17 | 3000 ms | 3768 KB |
#include "circuit.h" #include <vector> using namespace std; vector<int> a; using g_t = vector<vector<int>>; g_t g; using ll = long long; constexpr ll mod = 1000002022; void init(int N, int M, std::vector<int> P, std::vector<int> A) { g = g_t(N); for (int i = 1; i < N + M; ++i) { g[P[i]].push_back(i); } a = A; } int count_ways(int L, int R) { L -= g.size(); R -= g.size(); for (int i = L; i <= R; ++i) { a[i] = 1 - a[i]; } vector<ll> nuP(g.size()), nuT(g.size()); for (int i = g.size() - 1; i >= 0; --i) { ll su = 1; ll suMult = (g.size() + 1); ll allNot = 1; nuT[i] = g[i].size() + 1; for (auto e: g[i]) { if (e >= g.size()) { if (a[e - g.size()] == 1) { suMult = suMult + mod - su; suMult %= mod; allNot = 0; } } else { nuT[i] = (nuT[i] * nuT[e]) % mod; allNot = (allNot * ((nuT[e] - nuP[e] + mod) % mod)) % mod; suMult = ((suMult * nuT[e]) % mod - (su * nuP[e]) % mod + mod) % mod; su = (nuT[i] * su) % mod; } } nuP[i] = (suMult - allNot + mod) % mod; } return nuP.front(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | 2nd lines differ - on the 1st token, expected: '2', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | 2nd lines differ - on the 1st token, expected: '2', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | 2nd lines differ - on the 1st token, expected: '2', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3086 ms | 3768 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3086 ms | 3768 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | 2nd lines differ - on the 1st token, expected: '2', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | 2nd lines differ - on the 1st token, expected: '2', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | 2nd lines differ - on the 1st token, expected: '2', found: '0' |
2 | Halted | 0 ms | 0 KB | - |