답안 #807599

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
807599 2023-08-04T20:05:53 Z Ozy 디지털 회로 (IOI22_circuit) C++17
18 / 100
18 ms 2160 KB
#include "circuit.h"
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)
#define pll pair<lli,lli>

#define MAX 2000
#define mod 1000002022
//para el arreglo
#define unos first
#define ceros second

vector<lli> hijos[MAX+2];
lli n,m;
lli dp[MAX+2][MAX+2];
pll arr[MAX+2];

pll solve(lli pos) {
  pll res = {0,0};
  lli sig,apu = 0;
  lli tam = hijos[pos].size();
  rep(i,0,tam) dp[apu][i] = 0;
  dp[apu][0] = 1;

  for(auto h : hijos[pos]) {
    sig = apu^1;
    rep(i,0,tam) dp[sig][i] = 0;

    rep(i,0,tam) {
      dp[sig][i] += dp[apu][i] * arr[h].ceros;
      dp[sig][i+1] += dp[apu][i] * arr[h].unos;
    }
    rep(i,0,tam) dp[sig][i] %= mod;

    apu = sig;
  }

  lli u = 0;
  lli c = tam;
  rep(i,0,tam) {
    res.unos += dp[apu][i]*u;
    res.ceros += dp[apu][i]*c;
    u++;
    c--;
  }

  res.unos %= mod;
  res.ceros %= mod;
  return res;
}

void init(int N, int M, std::vector<int> P, std::vector<int> A) {
  n = N;
  m=M;
    
  rep(i,1,N+M-1) hijos[P[i]].push_back(i);
  rep(i,0,M-1) {
    if (A[i] == 0) arr[i+n] = {0,1};
    else arr[i+n] = {1,0};
  }
  repa(i,n-1,0) arr[i] = solve(i);
}

int count_ways(int L, int R) {

  rep(i,L,R) {
    arr[i].unos ^= 1;
    arr[i].ceros ^= 1;
  }
  repa(i,n-1,0) arr[i] = solve(i);
  return arr[0].unos;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 12 ms 336 KB Output is correct
4 Correct 14 ms 336 KB Output is correct
5 Correct 13 ms 420 KB Output is correct
6 Correct 13 ms 336 KB Output is correct
7 Correct 13 ms 336 KB Output is correct
8 Correct 13 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 12 ms 336 KB Output is correct
4 Correct 14 ms 336 KB Output is correct
5 Correct 13 ms 420 KB Output is correct
6 Correct 13 ms 336 KB Output is correct
7 Correct 13 ms 336 KB Output is correct
8 Correct 13 ms 336 KB Output is correct
9 Correct 0 ms 336 KB Output is correct
10 Correct 0 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 13 ms 336 KB Output is correct
30 Correct 14 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 3 ms 336 KB Output is correct
36 Correct 1 ms 336 KB Output is correct
37 Correct 14 ms 472 KB Output is correct
38 Correct 18 ms 464 KB Output is correct
39 Correct 1 ms 336 KB Output is correct
40 Correct 1 ms 336 KB Output is correct
41 Correct 1 ms 336 KB Output is correct
42 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 9 ms 2160 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 9 ms 2160 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Runtime error 9 ms 2160 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 12 ms 336 KB Output is correct
4 Correct 14 ms 336 KB Output is correct
5 Correct 13 ms 420 KB Output is correct
6 Correct 13 ms 336 KB Output is correct
7 Correct 13 ms 336 KB Output is correct
8 Correct 13 ms 336 KB Output is correct
9 Correct 0 ms 336 KB Output is correct
10 Correct 0 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 13 ms 336 KB Output is correct
30 Correct 14 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 3 ms 336 KB Output is correct
36 Correct 1 ms 336 KB Output is correct
37 Correct 14 ms 472 KB Output is correct
38 Correct 18 ms 464 KB Output is correct
39 Correct 1 ms 336 KB Output is correct
40 Correct 1 ms 336 KB Output is correct
41 Correct 1 ms 336 KB Output is correct
42 Correct 1 ms 336 KB Output is correct
43 Runtime error 2 ms 720 KB Execution killed with signal 11
44 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 12 ms 336 KB Output is correct
4 Correct 14 ms 336 KB Output is correct
5 Correct 13 ms 420 KB Output is correct
6 Correct 13 ms 336 KB Output is correct
7 Correct 13 ms 336 KB Output is correct
8 Correct 13 ms 336 KB Output is correct
9 Correct 0 ms 336 KB Output is correct
10 Correct 0 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 13 ms 336 KB Output is correct
30 Correct 14 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 3 ms 336 KB Output is correct
36 Correct 1 ms 336 KB Output is correct
37 Correct 14 ms 472 KB Output is correct
38 Correct 18 ms 464 KB Output is correct
39 Correct 1 ms 336 KB Output is correct
40 Correct 1 ms 336 KB Output is correct
41 Correct 1 ms 336 KB Output is correct
42 Correct 1 ms 336 KB Output is correct
43 Runtime error 9 ms 2160 KB Execution killed with signal 11
44 Halted 0 ms 0 KB -