Submission #1079844

# Submission time Handle Problem Language Result Execution time Memory
1079844 2024-08-29T02:28:10 Z LittleOrange Digital Circuit (IOI22_circuit) C++17
18 / 100
3000 ms 3672 KB
#include "circuit.h"

#include <vector>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000002022;
ll n,m;
vector<ll> p,a;
vector<vector<ll>> con;
void init(int N, int M, std::vector<int> P, std::vector<int> A) {
  n=N;
  m=M;
  p.assign(P.begin(),P.end());
  a.assign(A.begin(),A.end());
  con.resize(n);
  for(ll i = 1;i<n+m;i++) con[p[i]].push_back(i);
}
pair<ll,ll> dfs(ll i){// 0, 1
  if (i>=n) return {a[i-n]==0,a[i-n]==1};
  ll c = con[i].size();
  vector<ll> v(c+1,0),v0(c+1,0);
  v[0] = 1;
  for(ll j : con[i]){
    auto [x,y] = dfs(j);
    for(ll i = 0;i<c;i++){
      v0[i] += v[i]*x%mod;
      v0[i+1] += v[i]*y%mod;
    }
    v.swap(v0);
    fill(v0.begin(),v0.end(),0);
  }
  ll x = 0, y = 0;
  for(ll j = 0;j<=c;j++){
    x += v[j]*(c-j)%mod;
    y += v[j]*j%mod;
  }
  return {x%mod,y%mod};
}
int count_ways(int L, int R) {
  for(ll i = L;i<=R;i++) a[i-n]^=1;
  return dfs(0).second;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 15 ms 344 KB Output is correct
4 Correct 15 ms 344 KB Output is correct
5 Correct 15 ms 484 KB Output is correct
6 Correct 16 ms 344 KB Output is correct
7 Correct 15 ms 344 KB Output is correct
8 Correct 18 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 412 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 2 ms 600 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 15 ms 344 KB Output is correct
4 Correct 15 ms 344 KB Output is correct
5 Correct 15 ms 484 KB Output is correct
6 Correct 16 ms 344 KB Output is correct
7 Correct 15 ms 344 KB Output is correct
8 Correct 18 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 412 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 2 ms 600 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 16 ms 480 KB Output is correct
30 Correct 16 ms 344 KB Output is correct
31 Correct 1 ms 600 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 4 ms 344 KB Output is correct
36 Correct 1 ms 600 KB Output is correct
37 Correct 16 ms 728 KB Output is correct
38 Correct 16 ms 600 KB Output is correct
39 Correct 1 ms 344 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
41 Correct 1 ms 344 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3034 ms 3672 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3034 ms 3672 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 412 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 2 ms 600 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Execution timed out 3034 ms 3672 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 15 ms 344 KB Output is correct
4 Correct 15 ms 344 KB Output is correct
5 Correct 15 ms 484 KB Output is correct
6 Correct 16 ms 344 KB Output is correct
7 Correct 15 ms 344 KB Output is correct
8 Correct 18 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 412 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 2 ms 600 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 16 ms 480 KB Output is correct
30 Correct 16 ms 344 KB Output is correct
31 Correct 1 ms 600 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 4 ms 344 KB Output is correct
36 Correct 1 ms 600 KB Output is correct
37 Correct 16 ms 728 KB Output is correct
38 Correct 16 ms 600 KB Output is correct
39 Correct 1 ms 344 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
41 Correct 1 ms 344 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
43 Execution timed out 3055 ms 600 KB Time limit exceeded
44 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 15 ms 344 KB Output is correct
4 Correct 15 ms 344 KB Output is correct
5 Correct 15 ms 484 KB Output is correct
6 Correct 16 ms 344 KB Output is correct
7 Correct 15 ms 344 KB Output is correct
8 Correct 18 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 412 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 2 ms 600 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 16 ms 480 KB Output is correct
30 Correct 16 ms 344 KB Output is correct
31 Correct 1 ms 600 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 4 ms 344 KB Output is correct
36 Correct 1 ms 600 KB Output is correct
37 Correct 16 ms 728 KB Output is correct
38 Correct 16 ms 600 KB Output is correct
39 Correct 1 ms 344 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
41 Correct 1 ms 344 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
43 Execution timed out 3034 ms 3672 KB Time limit exceeded
44 Halted 0 ms 0 KB -