답안 #798665

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
798665 2023-07-30T22:34:16 Z JakobZorz 디지털 회로 (IOI22_circuit) C++17
6 / 100
3000 ms 10764 KB
#include"circuit.h"
#include<vector>
#include<iostream>
using namespace std;
typedef long long ll;

const int MOD=1000002022;

int parents[200000];
ll sub_mul[200000];
vector<int>children[200000];
int n,m;
vector<ll>vals;
vector<bool>active;
ll curr_res=0;

void dfs2(int node){
    if(children[node].empty()){
        sub_mul[node]=1;
        return;
    }
    
    sub_mul[node]=children[node].size();
    for(int ch:children[node]){
        dfs2(ch);
        sub_mul[node]*=sub_mul[ch];
        sub_mul[node]%=MOD;
    }
}

void dfs3(int node,ll val){
    if(children[node].empty()){
        vals.push_back(val);
        return;
    }
    
    for(int ch:children[node]){
        ll val2=val;
        for(int ch2:children[node]){
            if(ch2!=ch){
                val2*=sub_mul[ch2];
                val2%=MOD;
            }
        }
        dfs3(ch,val2);
    }
}

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++){
        parents[i]=P[i];
        if(parents[i]!=-1)
            children[parents[i]].push_back(i);
    }
    
    dfs2(0);
    dfs3(0,1);
    
    for(int i=0;i<(int)A.size();i++){
        if(A[i]==1){
            curr_res+=vals[i];
            curr_res%=MOD;
        }
        active.push_back(A[i]==1);
    }
}

int count_ways(int L, int R) {
    L-=n;
    R-=n;
    for(int i=L;i<=R;i++){
        if(active[i]){
            active[i]=false;
            curr_res+=MOD-vals[i];
            curr_res%=MOD;
        }else{
            active[i]=true;
            curr_res+=vals[i];
            curr_res%=MOD;
        }
    }
    
    /*for(int i=0;i<m;i++)
        cout<<active[i]<<" ";
    cout<<"\n";
    for(int i=0;i<m;i++)
        cout<<vals[i]<<" ";
    cout<<"\n";*/
    
    
    return (int)curr_res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4944 KB Output is correct
2 Correct 3 ms 4944 KB Output is correct
3 Correct 7 ms 5048 KB Output is correct
4 Correct 6 ms 5032 KB Output is correct
5 Correct 7 ms 5048 KB Output is correct
6 Correct 6 ms 4944 KB Output is correct
7 Correct 6 ms 4944 KB Output is correct
8 Correct 6 ms 5044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4944 KB Output is correct
2 Correct 2 ms 4944 KB Output is correct
3 Correct 2 ms 4944 KB Output is correct
4 Correct 2 ms 4944 KB Output is correct
5 Correct 3 ms 4944 KB Output is correct
6 Incorrect 2 ms 5072 KB 1st lines differ - on the 1st token, expected: '706880838', found: '638324092'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4944 KB Output is correct
2 Correct 3 ms 4944 KB Output is correct
3 Correct 7 ms 5048 KB Output is correct
4 Correct 6 ms 5032 KB Output is correct
5 Correct 7 ms 5048 KB Output is correct
6 Correct 6 ms 4944 KB Output is correct
7 Correct 6 ms 4944 KB Output is correct
8 Correct 6 ms 5044 KB Output is correct
9 Correct 3 ms 4944 KB Output is correct
10 Correct 2 ms 4944 KB Output is correct
11 Correct 2 ms 4944 KB Output is correct
12 Correct 2 ms 4944 KB Output is correct
13 Correct 3 ms 4944 KB Output is correct
14 Incorrect 2 ms 5072 KB 1st lines differ - on the 1st token, expected: '706880838', found: '638324092'
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 483 ms 7968 KB Output is correct
2 Correct 732 ms 10764 KB Output is correct
3 Correct 656 ms 10700 KB Output is correct
4 Correct 647 ms 10700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 483 ms 7968 KB Output is correct
2 Correct 732 ms 10764 KB Output is correct
3 Correct 656 ms 10700 KB Output is correct
4 Correct 647 ms 10700 KB Output is correct
5 Execution timed out 3088 ms 7948 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4944 KB Output is correct
2 Correct 2 ms 4944 KB Output is correct
3 Correct 2 ms 4944 KB Output is correct
4 Correct 2 ms 4944 KB Output is correct
5 Correct 3 ms 4944 KB Output is correct
6 Incorrect 2 ms 5072 KB 1st lines differ - on the 1st token, expected: '706880838', found: '638324092'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4944 KB Output is correct
2 Correct 3 ms 4944 KB Output is correct
3 Correct 7 ms 5048 KB Output is correct
4 Correct 6 ms 5032 KB Output is correct
5 Correct 7 ms 5048 KB Output is correct
6 Correct 6 ms 4944 KB Output is correct
7 Correct 6 ms 4944 KB Output is correct
8 Correct 6 ms 5044 KB Output is correct
9 Correct 3 ms 4944 KB Output is correct
10 Correct 2 ms 4944 KB Output is correct
11 Correct 2 ms 4944 KB Output is correct
12 Correct 2 ms 4944 KB Output is correct
13 Correct 3 ms 4944 KB Output is correct
14 Incorrect 2 ms 5072 KB 1st lines differ - on the 1st token, expected: '706880838', found: '638324092'
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4944 KB Output is correct
2 Correct 3 ms 4944 KB Output is correct
3 Correct 7 ms 5048 KB Output is correct
4 Correct 6 ms 5032 KB Output is correct
5 Correct 7 ms 5048 KB Output is correct
6 Correct 6 ms 4944 KB Output is correct
7 Correct 6 ms 4944 KB Output is correct
8 Correct 6 ms 5044 KB Output is correct
9 Correct 3 ms 4944 KB Output is correct
10 Correct 2 ms 4944 KB Output is correct
11 Correct 2 ms 4944 KB Output is correct
12 Correct 2 ms 4944 KB Output is correct
13 Correct 3 ms 4944 KB Output is correct
14 Incorrect 2 ms 5072 KB 1st lines differ - on the 1st token, expected: '706880838', found: '638324092'
15 Halted 0 ms 0 KB -