Submission #1024510

# Submission time Handle Problem Language Result Execution time Memory
1024510 2024-07-16T06:32:10 Z vjudge1 Digital Circuit (IOI22_circuit) C++17
9 / 100
14 ms 13008 KB
#include <bits/stdc++.h>
#define ent '\n'

using namespace std;
typedef long long ll;
const int maxn = 1e5 + 12;
const int mod = 1e9 + 2022;

vector<int> g[maxn];
ll dp[1005][1005];
ll ways[1005][2];
int p[maxn];
int a[maxn];
int n, m;

void init(int N, int M, std::vector<int> P, std::vector<int> A){
    n = N, m = M;
    for(int i=0;i<n+m;i++){
        p[i] = P[i];
        if(i >= n) a[i] = A[i-n];
        if(i >= 1) g[p[i]].push_back(i);
    }
}

int count_ways(int L, int R){
    for(int i=L;i<=R;i++){
        a[i] ^= 1;
    }
    for(int i=n;i<n+m;i++){
        ways[i][a[i]] = 1;
        ways[i][1-a[i]] = 0;
    }
    for(int v=n-1;v>=0;v--){
        for(int i=0;i<=n+m;i++){
            dp[v][i] = 0;
        }
        dp[v][0] = 1;
        ways[v][0] = ways[v][1] = 0;
        for(int to:g[v]){
            for(int i=g[v].size();i>=0;i--){
                dp[v][i] = (dp[v][i] * ways[to][0]) % mod;
                if(i > 0) dp[v][i] = (dp[v][i] + dp[v][i-1] * ways[to][1]) % mod;
            }
        }
        for(int i=0;i<=(int)g[v].size();i++){
            ways[v][0] = (ways[v][0] + dp[v][i] * ((int)g[v].size() - i)) % mod;
            ways[v][1] = (ways[v][1] + dp[v][i] * i) % mod;
        }
    }
    return ways[0][1];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4952 KB Output is correct
3 Correct 14 ms 4952 KB Output is correct
4 Correct 12 ms 4952 KB Output is correct
5 Correct 13 ms 4952 KB Output is correct
6 Correct 13 ms 4952 KB Output is correct
7 Correct 13 ms 4952 KB Output is correct
8 Correct 13 ms 4952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 7000 KB Output is correct
3 Correct 2 ms 9048 KB Output is correct
4 Correct 2 ms 9048 KB Output is correct
5 Correct 2 ms 9048 KB Output is correct
6 Correct 3 ms 11352 KB Output is correct
7 Correct 5 ms 11352 KB Output is correct
8 Correct 3 ms 11352 KB Output is correct
9 Correct 3 ms 11352 KB Output is correct
10 Correct 3 ms 11352 KB Output is correct
11 Correct 3 ms 11352 KB Output is correct
12 Correct 3 ms 11308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4952 KB Output is correct
3 Correct 14 ms 4952 KB Output is correct
4 Correct 12 ms 4952 KB Output is correct
5 Correct 13 ms 4952 KB Output is correct
6 Correct 13 ms 4952 KB Output is correct
7 Correct 13 ms 4952 KB Output is correct
8 Correct 13 ms 4952 KB Output is correct
9 Correct 1 ms 4952 KB Output is correct
10 Correct 1 ms 7000 KB Output is correct
11 Correct 2 ms 9048 KB Output is correct
12 Correct 2 ms 9048 KB Output is correct
13 Correct 2 ms 9048 KB Output is correct
14 Correct 3 ms 11352 KB Output is correct
15 Correct 5 ms 11352 KB Output is correct
16 Correct 3 ms 11352 KB Output is correct
17 Correct 3 ms 11352 KB Output is correct
18 Correct 3 ms 11352 KB Output is correct
19 Correct 3 ms 11352 KB Output is correct
20 Correct 3 ms 11308 KB Output is correct
21 Correct 3 ms 11352 KB Output is correct
22 Correct 2 ms 11352 KB Output is correct
23 Correct 2 ms 9048 KB Output is correct
24 Incorrect 3 ms 11352 KB 1st lines differ - on the 1st token, expected: '933758984', found: '0'
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 13008 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 13008 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 7000 KB Output is correct
3 Correct 2 ms 9048 KB Output is correct
4 Correct 2 ms 9048 KB Output is correct
5 Correct 2 ms 9048 KB Output is correct
6 Correct 3 ms 11352 KB Output is correct
7 Correct 5 ms 11352 KB Output is correct
8 Correct 3 ms 11352 KB Output is correct
9 Correct 3 ms 11352 KB Output is correct
10 Correct 3 ms 11352 KB Output is correct
11 Correct 3 ms 11352 KB Output is correct
12 Correct 3 ms 11308 KB Output is correct
13 Runtime error 12 ms 13008 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4952 KB Output is correct
3 Correct 14 ms 4952 KB Output is correct
4 Correct 12 ms 4952 KB Output is correct
5 Correct 13 ms 4952 KB Output is correct
6 Correct 13 ms 4952 KB Output is correct
7 Correct 13 ms 4952 KB Output is correct
8 Correct 13 ms 4952 KB Output is correct
9 Correct 1 ms 4952 KB Output is correct
10 Correct 1 ms 7000 KB Output is correct
11 Correct 2 ms 9048 KB Output is correct
12 Correct 2 ms 9048 KB Output is correct
13 Correct 2 ms 9048 KB Output is correct
14 Correct 3 ms 11352 KB Output is correct
15 Correct 5 ms 11352 KB Output is correct
16 Correct 3 ms 11352 KB Output is correct
17 Correct 3 ms 11352 KB Output is correct
18 Correct 3 ms 11352 KB Output is correct
19 Correct 3 ms 11352 KB Output is correct
20 Correct 3 ms 11308 KB Output is correct
21 Correct 3 ms 11352 KB Output is correct
22 Correct 2 ms 11352 KB Output is correct
23 Correct 2 ms 9048 KB Output is correct
24 Incorrect 3 ms 11352 KB 1st lines differ - on the 1st token, expected: '933758984', found: '0'
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4952 KB Output is correct
3 Correct 14 ms 4952 KB Output is correct
4 Correct 12 ms 4952 KB Output is correct
5 Correct 13 ms 4952 KB Output is correct
6 Correct 13 ms 4952 KB Output is correct
7 Correct 13 ms 4952 KB Output is correct
8 Correct 13 ms 4952 KB Output is correct
9 Correct 1 ms 4952 KB Output is correct
10 Correct 1 ms 7000 KB Output is correct
11 Correct 2 ms 9048 KB Output is correct
12 Correct 2 ms 9048 KB Output is correct
13 Correct 2 ms 9048 KB Output is correct
14 Correct 3 ms 11352 KB Output is correct
15 Correct 5 ms 11352 KB Output is correct
16 Correct 3 ms 11352 KB Output is correct
17 Correct 3 ms 11352 KB Output is correct
18 Correct 3 ms 11352 KB Output is correct
19 Correct 3 ms 11352 KB Output is correct
20 Correct 3 ms 11308 KB Output is correct
21 Correct 3 ms 11352 KB Output is correct
22 Correct 2 ms 11352 KB Output is correct
23 Correct 2 ms 9048 KB Output is correct
24 Incorrect 3 ms 11352 KB 1st lines differ - on the 1st token, expected: '933758984', found: '0'
25 Halted 0 ms 0 KB -