답안 #912672

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
912672 2024-01-19T17:51:56 Z biank 디지털 회로 (IOI22_circuit) C++17
18 / 100
23 ms 2700 KB
#include "circuit.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> ii;
#define ALL(x) x.begin(),x.end()
#define SIZE(x) (int)x.size()
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define dforsn(i,s,n) for(int i=int(n)-1;i>=int(s);i--)
#define dforn(i,n) for(int i=int(n)-1;i>=0;i--)
#define fst first
#define snd second
#define pb push_back
const int MAXN = 2000;
const int MOD = 1e9+2022;
vi s, adj[MAXN];
int n, m;

void init(int N, int M, vi P, vi A) {
    s=A, n=N, m=M;
    forsn(i,1,n+m) adj[P[i]].pb(i);
}

int mul(int x, int y) {
    return int(1LL* x * y % MOD);
}

void add(int &x, int v) {
    x+=v;
    if(x>=MOD) x-=MOD;
}

ii dfs(int u) {
    int c=SIZE(adj[u]);
    if(!c) return {!s[u-n], s[u-n]};
    vi ways(c+1,0);
    ways[0] = 1;
    forn(i,c) {
        ii child=dfs(adj[u][i]);
        dforn(j,c+1) {
            ways[j] = mul(ways[j],child.fst);
            if(j) add(ways[j],mul(ways[j-1],child.snd));
        }
    }
    ii ans = {0,0};
    forsn(i,1,c+1) {
        forn(j,i) add(ans.fst, ways[j]);
        forsn(j,i,c+1) add(ans.snd, ways[j]);
    }
    return ans;
}

int count_ways(int L, int R) {
    forsn(i,L,R+1) {
        s[i-n]^=1;
    }
    return int(dfs(0).snd);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 23 ms 464 KB Output is correct
4 Correct 22 ms 344 KB Output is correct
5 Correct 22 ms 344 KB Output is correct
6 Correct 22 ms 344 KB Output is correct
7 Correct 22 ms 344 KB Output is correct
8 Correct 22 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 484 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 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 23 ms 464 KB Output is correct
4 Correct 22 ms 344 KB Output is correct
5 Correct 22 ms 344 KB Output is correct
6 Correct 22 ms 344 KB Output is correct
7 Correct 22 ms 344 KB Output is correct
8 Correct 22 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 484 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 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 1 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 500 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 600 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 540 KB Output is correct
29 Correct 23 ms 344 KB Output is correct
30 Correct 22 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 5 ms 344 KB Output is correct
36 Correct 1 ms 600 KB Output is correct
37 Correct 23 ms 600 KB Output is correct
38 Correct 22 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
# 결과 실행 시간 메모리 Grader output
1 Runtime error 11 ms 2700 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 11 ms 2700 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 484 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 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Runtime error 11 ms 2700 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 23 ms 464 KB Output is correct
4 Correct 22 ms 344 KB Output is correct
5 Correct 22 ms 344 KB Output is correct
6 Correct 22 ms 344 KB Output is correct
7 Correct 22 ms 344 KB Output is correct
8 Correct 22 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 484 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 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 1 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 500 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 600 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 540 KB Output is correct
29 Correct 23 ms 344 KB Output is correct
30 Correct 22 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 5 ms 344 KB Output is correct
36 Correct 1 ms 600 KB Output is correct
37 Correct 23 ms 600 KB Output is correct
38 Correct 22 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 Runtime error 3 ms 856 KB Execution killed with signal 11
44 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 23 ms 464 KB Output is correct
4 Correct 22 ms 344 KB Output is correct
5 Correct 22 ms 344 KB Output is correct
6 Correct 22 ms 344 KB Output is correct
7 Correct 22 ms 344 KB Output is correct
8 Correct 22 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 484 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 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 1 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 500 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 600 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 540 KB Output is correct
29 Correct 23 ms 344 KB Output is correct
30 Correct 22 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 5 ms 344 KB Output is correct
36 Correct 1 ms 600 KB Output is correct
37 Correct 23 ms 600 KB Output is correct
38 Correct 22 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 Runtime error 11 ms 2700 KB Execution killed with signal 11
44 Halted 0 ms 0 KB -