Submission #1024486

# Submission time Handle Problem Language Result Execution time Memory
1024486 2024-07-16T05:52:45 Z vjudge1 Digital Circuit (IOI22_circuit) C++17
9 / 100
3000 ms 8376 KB
#include "circuit.h"
#include <bits/stdc++.h>

#define ll long long
#define sz(s) (int)s.size()
#define pb push_back

using namespace std;

const int MAX=2e5+10;
const int mod=1000002022;

int n,m;
vector<int> a;
vector<int> g[MAX];
int dp[MAX],s[MAX];

void dfs(int v){
    if(g[v].empty()){
        dp[v]=a[v-n];
        s[v]=1;
        return;
    }
    s[v]=sz(g[v]);
    for(auto to:g[v]){
        dfs(to);
        s[v]=s[v]*1ll*s[to]%mod;
    }
    vector<int> d(n+m,0);
    d[0]=1;
    for(int i=0;i<sz(g[v]);i++){
        int to=g[v][i];
        for(int j=i+1;j>=0;j--){
            int p=d[j];
            d[j]=d[j]*1ll*(s[to]-dp[to]+mod)%mod;
            if(j-1>=0)d[j]+=d[j-1]*1ll*dp[to]%mod;
            d[j]%=mod;
        }
    }
    for(int i=1;i<=sz(g[v]);i++){
        dp[v]+=i*d[i]%mod;
        dp[v]%=mod;
    }
}

void init(int N, int M,vector<int> P,vector<int> A) {
    n=N;
    m=M;
    a=A;
    for(int i=1;i<N+M;i++){
        g[P[i]].pb(i);
    }
}

int count_ways(int L, int R) {
    for(int i=0;i<n+m;i++)dp[i]=0;
    for(int i=L;i<=R;i++)a[i-n]^=1;
    dfs(0);
    // for(int i=0;i<n;i++)cout<<dp[i]<<" "<<(s[i]-dp[i])<<"\n";
    // cout<<"\n";
    return dp[0];
}

Compilation message

circuit.cpp: In function 'void dfs(int)':
circuit.cpp:34:17: warning: unused variable 'p' [-Wunused-variable]
   34 |             int p=d[j];
      |                 ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6488 KB Output is correct
2 Correct 1 ms 6488 KB Output is correct
3 Correct 12 ms 6488 KB Output is correct
4 Correct 12 ms 6488 KB Output is correct
5 Correct 12 ms 6488 KB Output is correct
6 Correct 12 ms 6488 KB Output is correct
7 Correct 13 ms 6488 KB Output is correct
8 Correct 12 ms 6488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6488 KB Output is correct
2 Correct 2 ms 6324 KB Output is correct
3 Correct 2 ms 6488 KB Output is correct
4 Correct 2 ms 6488 KB Output is correct
5 Correct 2 ms 6488 KB Output is correct
6 Correct 2 ms 6488 KB Output is correct
7 Correct 3 ms 6580 KB Output is correct
8 Correct 3 ms 6488 KB Output is correct
9 Correct 2 ms 6488 KB Output is correct
10 Correct 3 ms 6488 KB Output is correct
11 Correct 3 ms 6740 KB Output is correct
12 Correct 3 ms 6488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6488 KB Output is correct
2 Correct 1 ms 6488 KB Output is correct
3 Correct 12 ms 6488 KB Output is correct
4 Correct 12 ms 6488 KB Output is correct
5 Correct 12 ms 6488 KB Output is correct
6 Correct 12 ms 6488 KB Output is correct
7 Correct 13 ms 6488 KB Output is correct
8 Correct 12 ms 6488 KB Output is correct
9 Correct 2 ms 6488 KB Output is correct
10 Correct 2 ms 6324 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 2 ms 6488 KB Output is correct
13 Correct 2 ms 6488 KB Output is correct
14 Correct 2 ms 6488 KB Output is correct
15 Correct 3 ms 6580 KB Output is correct
16 Correct 3 ms 6488 KB Output is correct
17 Correct 2 ms 6488 KB Output is correct
18 Correct 3 ms 6488 KB Output is correct
19 Correct 3 ms 6740 KB Output is correct
20 Correct 3 ms 6488 KB Output is correct
21 Incorrect 2 ms 6488 KB 1st lines differ - on the 1st token, expected: '759476520', found: '921787348'
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3053 ms 8376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3053 ms 8376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6488 KB Output is correct
2 Correct 2 ms 6324 KB Output is correct
3 Correct 2 ms 6488 KB Output is correct
4 Correct 2 ms 6488 KB Output is correct
5 Correct 2 ms 6488 KB Output is correct
6 Correct 2 ms 6488 KB Output is correct
7 Correct 3 ms 6580 KB Output is correct
8 Correct 3 ms 6488 KB Output is correct
9 Correct 2 ms 6488 KB Output is correct
10 Correct 3 ms 6488 KB Output is correct
11 Correct 3 ms 6740 KB Output is correct
12 Correct 3 ms 6488 KB Output is correct
13 Execution timed out 3053 ms 8376 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6488 KB Output is correct
2 Correct 1 ms 6488 KB Output is correct
3 Correct 12 ms 6488 KB Output is correct
4 Correct 12 ms 6488 KB Output is correct
5 Correct 12 ms 6488 KB Output is correct
6 Correct 12 ms 6488 KB Output is correct
7 Correct 13 ms 6488 KB Output is correct
8 Correct 12 ms 6488 KB Output is correct
9 Correct 2 ms 6488 KB Output is correct
10 Correct 2 ms 6324 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 2 ms 6488 KB Output is correct
13 Correct 2 ms 6488 KB Output is correct
14 Correct 2 ms 6488 KB Output is correct
15 Correct 3 ms 6580 KB Output is correct
16 Correct 3 ms 6488 KB Output is correct
17 Correct 2 ms 6488 KB Output is correct
18 Correct 3 ms 6488 KB Output is correct
19 Correct 3 ms 6740 KB Output is correct
20 Correct 3 ms 6488 KB Output is correct
21 Incorrect 2 ms 6488 KB 1st lines differ - on the 1st token, expected: '759476520', found: '921787348'
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6488 KB Output is correct
2 Correct 1 ms 6488 KB Output is correct
3 Correct 12 ms 6488 KB Output is correct
4 Correct 12 ms 6488 KB Output is correct
5 Correct 12 ms 6488 KB Output is correct
6 Correct 12 ms 6488 KB Output is correct
7 Correct 13 ms 6488 KB Output is correct
8 Correct 12 ms 6488 KB Output is correct
9 Correct 2 ms 6488 KB Output is correct
10 Correct 2 ms 6324 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 2 ms 6488 KB Output is correct
13 Correct 2 ms 6488 KB Output is correct
14 Correct 2 ms 6488 KB Output is correct
15 Correct 3 ms 6580 KB Output is correct
16 Correct 3 ms 6488 KB Output is correct
17 Correct 2 ms 6488 KB Output is correct
18 Correct 3 ms 6488 KB Output is correct
19 Correct 3 ms 6740 KB Output is correct
20 Correct 3 ms 6488 KB Output is correct
21 Incorrect 2 ms 6488 KB 1st lines differ - on the 1st token, expected: '759476520', found: '921787348'
22 Halted 0 ms 0 KB -