Submission #825722

# Submission time Handle Problem Language Result Execution time Memory
825722 2023-08-15T07:22:58 Z LittleCube Digital Circuit (IOI22_circuit) C++17
18 / 100
3000 ms 7948 KB
#include "circuit.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;

const ll mod = 1'000'002'022;
namespace
{
  int N, M;
  vector<int> P, A, c;
  vector<int> child[200005];
  ll zero[200005], one[200005];
}

void init(int N, int M, vector<int> P, vector<int> A)
{
  ::N = N;
  ::M = M;
  ::P = P;
  ::A = A;
  c.resize(N);
  for (int i = 1; i < N + M; i++)
    c[P[i]]++, child[P[i]].emplace_back(i);
}

int count_ways(int L, int R)
{
  L -= N, R -= N;
  for (int i = L; i <= R; i++)
    A[i] ^= 1;
  for (int i = M - 1; i >= 0; i--)
    if(A[i] == 1)
      zero[N + i] = 0, one[N + i] = 1;
    else 
      zero[N + i] = 1, one[N + i] = 0;
  for (int i = N - 1; i >= 0; i--)
  {
    int K = child[i].size();
    vector<ll> dp(K + 1, 0);
    dp[0] = 1;
    for (auto j : child[i])
      for (int k = K - 1; k >= 0; k--)
      {
        dp[k + 1] = (dp[k + 1] + dp[k] * one[j]) % mod;
        dp[k] = (dp[k] * zero[j]) % mod;
      }
    zero[i] = one[i] = 0;
    for (int k = 0; k <= K; k++)
    {
      zero[i] = (zero[i] + (K - k) * dp[k]) % mod;
      one[i] = (one[i] + k * dp[k]) % mod;
    }
  }
  return one[0];
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4944 KB Output is correct
2 Correct 2 ms 4944 KB Output is correct
3 Correct 14 ms 4944 KB Output is correct
4 Correct 14 ms 4944 KB Output is correct
5 Correct 15 ms 5048 KB Output is correct
6 Correct 15 ms 4944 KB Output is correct
7 Correct 15 ms 5044 KB Output is correct
8 Correct 14 ms 5056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4944 KB Output is correct
2 Correct 2 ms 4944 KB Output is correct
3 Correct 2 ms 4944 KB Output is correct
4 Correct 3 ms 4944 KB Output is correct
5 Correct 3 ms 4944 KB Output is correct
6 Correct 3 ms 5072 KB Output is correct
7 Correct 3 ms 5020 KB Output is correct
8 Correct 3 ms 5072 KB Output is correct
9 Correct 3 ms 5072 KB Output is correct
10 Correct 4 ms 5072 KB Output is correct
11 Correct 3 ms 5072 KB Output is correct
12 Correct 4 ms 5072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4944 KB Output is correct
2 Correct 2 ms 4944 KB Output is correct
3 Correct 14 ms 4944 KB Output is correct
4 Correct 14 ms 4944 KB Output is correct
5 Correct 15 ms 5048 KB Output is correct
6 Correct 15 ms 4944 KB Output is correct
7 Correct 15 ms 5044 KB Output is correct
8 Correct 14 ms 5056 KB Output is correct
9 Correct 2 ms 4944 KB Output is correct
10 Correct 2 ms 4944 KB Output is correct
11 Correct 2 ms 4944 KB Output is correct
12 Correct 3 ms 4944 KB Output is correct
13 Correct 3 ms 4944 KB Output is correct
14 Correct 3 ms 5072 KB Output is correct
15 Correct 3 ms 5020 KB Output is correct
16 Correct 3 ms 5072 KB Output is correct
17 Correct 3 ms 5072 KB Output is correct
18 Correct 4 ms 5072 KB Output is correct
19 Correct 3 ms 5072 KB Output is correct
20 Correct 4 ms 5072 KB Output is correct
21 Correct 3 ms 5072 KB Output is correct
22 Correct 3 ms 4944 KB Output is correct
23 Correct 3 ms 4944 KB Output is correct
24 Correct 3 ms 5072 KB Output is correct
25 Correct 3 ms 5072 KB Output is correct
26 Correct 3 ms 5072 KB Output is correct
27 Correct 4 ms 5072 KB Output is correct
28 Correct 3 ms 5072 KB Output is correct
29 Correct 15 ms 5052 KB Output is correct
30 Correct 15 ms 4944 KB Output is correct
31 Correct 2 ms 4944 KB Output is correct
32 Correct 3 ms 5072 KB Output is correct
33 Correct 3 ms 5072 KB Output is correct
34 Correct 2 ms 4944 KB Output is correct
35 Correct 5 ms 4944 KB Output is correct
36 Correct 3 ms 5104 KB Output is correct
37 Correct 15 ms 5072 KB Output is correct
38 Correct 15 ms 5072 KB Output is correct
39 Correct 3 ms 4944 KB Output is correct
40 Correct 3 ms 4944 KB Output is correct
41 Correct 3 ms 4944 KB Output is correct
42 Correct 3 ms 4944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3086 ms 7948 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3086 ms 7948 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4944 KB Output is correct
2 Correct 2 ms 4944 KB Output is correct
3 Correct 2 ms 4944 KB Output is correct
4 Correct 3 ms 4944 KB Output is correct
5 Correct 3 ms 4944 KB Output is correct
6 Correct 3 ms 5072 KB Output is correct
7 Correct 3 ms 5020 KB Output is correct
8 Correct 3 ms 5072 KB Output is correct
9 Correct 3 ms 5072 KB Output is correct
10 Correct 4 ms 5072 KB Output is correct
11 Correct 3 ms 5072 KB Output is correct
12 Correct 4 ms 5072 KB Output is correct
13 Execution timed out 3086 ms 7948 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4944 KB Output is correct
2 Correct 2 ms 4944 KB Output is correct
3 Correct 14 ms 4944 KB Output is correct
4 Correct 14 ms 4944 KB Output is correct
5 Correct 15 ms 5048 KB Output is correct
6 Correct 15 ms 4944 KB Output is correct
7 Correct 15 ms 5044 KB Output is correct
8 Correct 14 ms 5056 KB Output is correct
9 Correct 2 ms 4944 KB Output is correct
10 Correct 2 ms 4944 KB Output is correct
11 Correct 2 ms 4944 KB Output is correct
12 Correct 3 ms 4944 KB Output is correct
13 Correct 3 ms 4944 KB Output is correct
14 Correct 3 ms 5072 KB Output is correct
15 Correct 3 ms 5020 KB Output is correct
16 Correct 3 ms 5072 KB Output is correct
17 Correct 3 ms 5072 KB Output is correct
18 Correct 4 ms 5072 KB Output is correct
19 Correct 3 ms 5072 KB Output is correct
20 Correct 4 ms 5072 KB Output is correct
21 Correct 3 ms 5072 KB Output is correct
22 Correct 3 ms 4944 KB Output is correct
23 Correct 3 ms 4944 KB Output is correct
24 Correct 3 ms 5072 KB Output is correct
25 Correct 3 ms 5072 KB Output is correct
26 Correct 3 ms 5072 KB Output is correct
27 Correct 4 ms 5072 KB Output is correct
28 Correct 3 ms 5072 KB Output is correct
29 Correct 15 ms 5052 KB Output is correct
30 Correct 15 ms 4944 KB Output is correct
31 Correct 2 ms 4944 KB Output is correct
32 Correct 3 ms 5072 KB Output is correct
33 Correct 3 ms 5072 KB Output is correct
34 Correct 2 ms 4944 KB Output is correct
35 Correct 5 ms 4944 KB Output is correct
36 Correct 3 ms 5104 KB Output is correct
37 Correct 15 ms 5072 KB Output is correct
38 Correct 15 ms 5072 KB Output is correct
39 Correct 3 ms 4944 KB Output is correct
40 Correct 3 ms 4944 KB Output is correct
41 Correct 3 ms 4944 KB Output is correct
42 Correct 3 ms 4944 KB Output is correct
43 Execution timed out 3049 ms 5200 KB Time limit exceeded
44 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4944 KB Output is correct
2 Correct 2 ms 4944 KB Output is correct
3 Correct 14 ms 4944 KB Output is correct
4 Correct 14 ms 4944 KB Output is correct
5 Correct 15 ms 5048 KB Output is correct
6 Correct 15 ms 4944 KB Output is correct
7 Correct 15 ms 5044 KB Output is correct
8 Correct 14 ms 5056 KB Output is correct
9 Correct 2 ms 4944 KB Output is correct
10 Correct 2 ms 4944 KB Output is correct
11 Correct 2 ms 4944 KB Output is correct
12 Correct 3 ms 4944 KB Output is correct
13 Correct 3 ms 4944 KB Output is correct
14 Correct 3 ms 5072 KB Output is correct
15 Correct 3 ms 5020 KB Output is correct
16 Correct 3 ms 5072 KB Output is correct
17 Correct 3 ms 5072 KB Output is correct
18 Correct 4 ms 5072 KB Output is correct
19 Correct 3 ms 5072 KB Output is correct
20 Correct 4 ms 5072 KB Output is correct
21 Correct 3 ms 5072 KB Output is correct
22 Correct 3 ms 4944 KB Output is correct
23 Correct 3 ms 4944 KB Output is correct
24 Correct 3 ms 5072 KB Output is correct
25 Correct 3 ms 5072 KB Output is correct
26 Correct 3 ms 5072 KB Output is correct
27 Correct 4 ms 5072 KB Output is correct
28 Correct 3 ms 5072 KB Output is correct
29 Correct 15 ms 5052 KB Output is correct
30 Correct 15 ms 4944 KB Output is correct
31 Correct 2 ms 4944 KB Output is correct
32 Correct 3 ms 5072 KB Output is correct
33 Correct 3 ms 5072 KB Output is correct
34 Correct 2 ms 4944 KB Output is correct
35 Correct 5 ms 4944 KB Output is correct
36 Correct 3 ms 5104 KB Output is correct
37 Correct 15 ms 5072 KB Output is correct
38 Correct 15 ms 5072 KB Output is correct
39 Correct 3 ms 4944 KB Output is correct
40 Correct 3 ms 4944 KB Output is correct
41 Correct 3 ms 4944 KB Output is correct
42 Correct 3 ms 4944 KB Output is correct
43 Execution timed out 3086 ms 7948 KB Time limit exceeded
44 Halted 0 ms 0 KB -