답안 #869238

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
869238 2023-11-03T16:02:57 Z abcvuitunggio 디지털 회로 (IOI22_circuit) C++17
89 / 100
615 ms 31740 KB
#include "circuit.h"
#include <vector>
using namespace std;
const int mod=1000002022;
struct T{
    int sum,val;
}st[800001];
T operator +(T a, T b){
    return {(a.sum+b.sum)%mod,(a.val+b.val)%mod};
}
int n,a[200001],b[200001],lazy[200001],c[200001];
void down(int node, int l, int r){
    if (!lazy[node]||l==r)
        return;
    st[node<<1].val=(st[node<<1].sum-st[node<<1].val+mod)%mod;
    lazy[node<<1]^=1;
    st[node<<1|1].val=(st[node<<1|1].sum-st[node<<1|1].val+mod)%mod;
    lazy[node<<1|1]^=1;
    lazy[node]=0;
}
void build(int node, int l, int r){
    if (l==r){
        st[node]={b[l],a[l]*b[l]};
        return;
    }
    int mid=(l+r)>>1;
    build(node<<1,l,mid);
    build(node<<1|1,mid+1,r);
    st[node]=st[node<<1]+st[node<<1|1];
}
void update(int node, int l, int r, int u, int v){
    if (l>v||r<u||l>r||u>v)
        return;
    if (l>=u&&r<=v){
        lazy[node]^=1;
        st[node].val=(st[node].sum-st[node].val+mod)%mod;
        return;
    }
    down(node,l,r);
    int mid=(l+r)>>1;
    update(node<<1,l,mid,u,v);
    update(node<<1|1,mid+1,r,u,v);
    st[node]=st[node<<1]+st[node<<1|1];
}
vector <int> ke[200001];
void dfs(int u){
    if (ke[u].empty()){
        c[u]=1;
        return;
    }
    c[u]=ke[u].size();
    for (int v:ke[u]){
        dfs(v);
        c[u]=1LL*c[u]*c[v]%mod;
    }
}
void dfs2(int u, int val){
    if (ke[u].empty()){
        b[u]=val;
        return;
    }
    int d[ke[u].size()];
    for (int i=0;i<ke[u].size();i++)
        d[i]=1LL*(i?d[i-1]:1)*c[ke[u][i]]%mod;
    int cur=1;
    for (int i=ke[u].size()-1;i>=0;i--){
        dfs2(ke[u][i],(1LL*cur*(i?d[i-1]:1)%mod*val)%mod);
        cur=1LL*cur*c[ke[u][i]]%mod;
    }
}
void init(int N, int M, vector <int> P, vector <int> A){
    n=N+M;
    for (int i=0;i<M;i++)
        a[N+i]=A[i];
    for (int i=1;i<N+M;i++)
        ke[P[i]].push_back(i);
    dfs(0);
    dfs2(0,1);
    build(1,0,n-1);
}
int count_ways(int L, int R){
    update(1,0,n-1,L,R);
    return st[1].val;
}

Compilation message

circuit.cpp: In function 'void dfs2(int, int)':
circuit.cpp:63:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |     for (int i=0;i<ke[u].size();i++)
      |                  ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 9560 KB Output is correct
2 Correct 2 ms 9812 KB Output is correct
3 Correct 2 ms 9560 KB Output is correct
4 Correct 2 ms 9560 KB Output is correct
5 Correct 2 ms 9560 KB Output is correct
6 Correct 2 ms 9560 KB Output is correct
7 Correct 2 ms 9560 KB Output is correct
8 Correct 2 ms 9560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 9560 KB Output is correct
2 Correct 2 ms 9560 KB Output is correct
3 Correct 2 ms 9560 KB Output is correct
4 Correct 2 ms 9560 KB Output is correct
5 Correct 2 ms 9560 KB Output is correct
6 Correct 2 ms 9560 KB Output is correct
7 Correct 2 ms 9560 KB Output is correct
8 Correct 2 ms 9560 KB Output is correct
9 Correct 2 ms 9560 KB Output is correct
10 Correct 2 ms 9816 KB Output is correct
11 Correct 2 ms 9816 KB Output is correct
12 Correct 2 ms 9560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 9560 KB Output is correct
2 Correct 2 ms 9812 KB Output is correct
3 Correct 2 ms 9560 KB Output is correct
4 Correct 2 ms 9560 KB Output is correct
5 Correct 2 ms 9560 KB Output is correct
6 Correct 2 ms 9560 KB Output is correct
7 Correct 2 ms 9560 KB Output is correct
8 Correct 2 ms 9560 KB Output is correct
9 Correct 2 ms 9560 KB Output is correct
10 Correct 2 ms 9560 KB Output is correct
11 Correct 2 ms 9560 KB Output is correct
12 Correct 2 ms 9560 KB Output is correct
13 Correct 2 ms 9560 KB Output is correct
14 Correct 2 ms 9560 KB Output is correct
15 Correct 2 ms 9560 KB Output is correct
16 Correct 2 ms 9560 KB Output is correct
17 Correct 2 ms 9560 KB Output is correct
18 Correct 2 ms 9816 KB Output is correct
19 Correct 2 ms 9816 KB Output is correct
20 Correct 2 ms 9560 KB Output is correct
21 Correct 2 ms 9560 KB Output is correct
22 Correct 2 ms 9812 KB Output is correct
23 Correct 2 ms 9812 KB Output is correct
24 Correct 2 ms 9560 KB Output is correct
25 Correct 2 ms 9560 KB Output is correct
26 Correct 2 ms 9560 KB Output is correct
27 Correct 2 ms 9560 KB Output is correct
28 Correct 2 ms 9560 KB Output is correct
29 Correct 2 ms 9636 KB Output is correct
30 Correct 2 ms 9560 KB Output is correct
31 Correct 2 ms 9816 KB Output is correct
32 Correct 2 ms 9560 KB Output is correct
33 Correct 2 ms 9624 KB Output is correct
34 Correct 2 ms 9560 KB Output is correct
35 Correct 2 ms 9560 KB Output is correct
36 Correct 2 ms 9816 KB Output is correct
37 Correct 2 ms 9816 KB Output is correct
38 Correct 2 ms 9816 KB Output is correct
39 Correct 2 ms 9560 KB Output is correct
40 Correct 2 ms 9560 KB Output is correct
41 Correct 2 ms 9560 KB Output is correct
42 Correct 2 ms 9560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 368 ms 11296 KB Output is correct
2 Correct 557 ms 15296 KB Output is correct
3 Correct 519 ms 15288 KB Output is correct
4 Correct 540 ms 15292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 368 ms 11296 KB Output is correct
2 Correct 557 ms 15296 KB Output is correct
3 Correct 519 ms 15288 KB Output is correct
4 Correct 540 ms 15292 KB Output is correct
5 Correct 461 ms 11352 KB Output is correct
6 Correct 615 ms 15564 KB Output is correct
7 Correct 562 ms 15288 KB Output is correct
8 Correct 541 ms 15464 KB Output is correct
9 Correct 260 ms 9560 KB Output is correct
10 Correct 546 ms 9816 KB Output is correct
11 Correct 525 ms 9816 KB Output is correct
12 Correct 489 ms 9816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 9560 KB Output is correct
2 Correct 2 ms 9560 KB Output is correct
3 Correct 2 ms 9560 KB Output is correct
4 Correct 2 ms 9560 KB Output is correct
5 Correct 2 ms 9560 KB Output is correct
6 Correct 2 ms 9560 KB Output is correct
7 Correct 2 ms 9560 KB Output is correct
8 Correct 2 ms 9560 KB Output is correct
9 Correct 2 ms 9560 KB Output is correct
10 Correct 2 ms 9816 KB Output is correct
11 Correct 2 ms 9816 KB Output is correct
12 Correct 2 ms 9560 KB Output is correct
13 Correct 368 ms 11296 KB Output is correct
14 Correct 557 ms 15296 KB Output is correct
15 Correct 519 ms 15288 KB Output is correct
16 Correct 540 ms 15292 KB Output is correct
17 Correct 461 ms 11352 KB Output is correct
18 Correct 615 ms 15564 KB Output is correct
19 Correct 562 ms 15288 KB Output is correct
20 Correct 541 ms 15464 KB Output is correct
21 Correct 260 ms 9560 KB Output is correct
22 Correct 546 ms 9816 KB Output is correct
23 Correct 525 ms 9816 KB Output is correct
24 Correct 489 ms 9816 KB Output is correct
25 Correct 575 ms 19140 KB Output is correct
26 Correct 607 ms 19020 KB Output is correct
27 Correct 595 ms 19016 KB Output is correct
28 Correct 486 ms 19012 KB Output is correct
29 Correct 566 ms 31740 KB Output is correct
30 Correct 574 ms 31740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 9560 KB Output is correct
2 Correct 2 ms 9812 KB Output is correct
3 Correct 2 ms 9560 KB Output is correct
4 Correct 2 ms 9560 KB Output is correct
5 Correct 2 ms 9560 KB Output is correct
6 Correct 2 ms 9560 KB Output is correct
7 Correct 2 ms 9560 KB Output is correct
8 Correct 2 ms 9560 KB Output is correct
9 Correct 2 ms 9560 KB Output is correct
10 Correct 2 ms 9560 KB Output is correct
11 Correct 2 ms 9560 KB Output is correct
12 Correct 2 ms 9560 KB Output is correct
13 Correct 2 ms 9560 KB Output is correct
14 Correct 2 ms 9560 KB Output is correct
15 Correct 2 ms 9560 KB Output is correct
16 Correct 2 ms 9560 KB Output is correct
17 Correct 2 ms 9560 KB Output is correct
18 Correct 2 ms 9816 KB Output is correct
19 Correct 2 ms 9816 KB Output is correct
20 Correct 2 ms 9560 KB Output is correct
21 Correct 2 ms 9560 KB Output is correct
22 Correct 2 ms 9812 KB Output is correct
23 Correct 2 ms 9812 KB Output is correct
24 Correct 2 ms 9560 KB Output is correct
25 Correct 2 ms 9560 KB Output is correct
26 Correct 2 ms 9560 KB Output is correct
27 Correct 2 ms 9560 KB Output is correct
28 Correct 2 ms 9560 KB Output is correct
29 Correct 2 ms 9636 KB Output is correct
30 Correct 2 ms 9560 KB Output is correct
31 Correct 2 ms 9816 KB Output is correct
32 Correct 2 ms 9560 KB Output is correct
33 Correct 2 ms 9624 KB Output is correct
34 Correct 2 ms 9560 KB Output is correct
35 Correct 2 ms 9560 KB Output is correct
36 Correct 2 ms 9816 KB Output is correct
37 Correct 2 ms 9816 KB Output is correct
38 Correct 2 ms 9816 KB Output is correct
39 Correct 2 ms 9560 KB Output is correct
40 Correct 2 ms 9560 KB Output is correct
41 Correct 2 ms 9560 KB Output is correct
42 Correct 2 ms 9560 KB Output is correct
43 Correct 337 ms 9560 KB Output is correct
44 Correct 483 ms 9816 KB Output is correct
45 Correct 542 ms 9816 KB Output is correct
46 Correct 514 ms 9816 KB Output is correct
47 Correct 532 ms 9816 KB Output is correct
48 Correct 518 ms 10148 KB Output is correct
49 Correct 497 ms 9816 KB Output is correct
50 Correct 507 ms 9816 KB Output is correct
51 Correct 536 ms 9560 KB Output is correct
52 Correct 512 ms 9560 KB Output is correct
53 Correct 495 ms 10328 KB Output is correct
54 Correct 526 ms 9816 KB Output is correct
55 Correct 533 ms 9816 KB Output is correct
56 Correct 501 ms 9816 KB Output is correct
57 Correct 508 ms 9560 KB Output is correct
58 Correct 518 ms 10328 KB Output is correct
59 Correct 532 ms 10600 KB Output is correct
60 Correct 495 ms 10600 KB Output is correct
61 Correct 517 ms 9816 KB Output is correct
62 Correct 501 ms 9560 KB Output is correct
63 Correct 509 ms 9932 KB Output is correct
64 Correct 531 ms 9560 KB Output is correct
65 Correct 260 ms 9560 KB Output is correct
66 Correct 525 ms 9816 KB Output is correct
67 Correct 504 ms 9816 KB Output is correct
68 Correct 526 ms 9816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 9560 KB Output is correct
2 Correct 2 ms 9812 KB Output is correct
3 Correct 2 ms 9560 KB Output is correct
4 Correct 2 ms 9560 KB Output is correct
5 Correct 2 ms 9560 KB Output is correct
6 Correct 2 ms 9560 KB Output is correct
7 Correct 2 ms 9560 KB Output is correct
8 Correct 2 ms 9560 KB Output is correct
9 Correct 2 ms 9560 KB Output is correct
10 Correct 2 ms 9560 KB Output is correct
11 Correct 2 ms 9560 KB Output is correct
12 Correct 2 ms 9560 KB Output is correct
13 Correct 2 ms 9560 KB Output is correct
14 Correct 2 ms 9560 KB Output is correct
15 Correct 2 ms 9560 KB Output is correct
16 Correct 2 ms 9560 KB Output is correct
17 Correct 2 ms 9560 KB Output is correct
18 Correct 2 ms 9816 KB Output is correct
19 Correct 2 ms 9816 KB Output is correct
20 Correct 2 ms 9560 KB Output is correct
21 Correct 2 ms 9560 KB Output is correct
22 Correct 2 ms 9812 KB Output is correct
23 Correct 2 ms 9812 KB Output is correct
24 Correct 2 ms 9560 KB Output is correct
25 Correct 2 ms 9560 KB Output is correct
26 Correct 2 ms 9560 KB Output is correct
27 Correct 2 ms 9560 KB Output is correct
28 Correct 2 ms 9560 KB Output is correct
29 Correct 2 ms 9636 KB Output is correct
30 Correct 2 ms 9560 KB Output is correct
31 Correct 2 ms 9816 KB Output is correct
32 Correct 2 ms 9560 KB Output is correct
33 Correct 2 ms 9624 KB Output is correct
34 Correct 2 ms 9560 KB Output is correct
35 Correct 2 ms 9560 KB Output is correct
36 Correct 2 ms 9816 KB Output is correct
37 Correct 2 ms 9816 KB Output is correct
38 Correct 2 ms 9816 KB Output is correct
39 Correct 2 ms 9560 KB Output is correct
40 Correct 2 ms 9560 KB Output is correct
41 Correct 2 ms 9560 KB Output is correct
42 Correct 2 ms 9560 KB Output is correct
43 Correct 368 ms 11296 KB Output is correct
44 Correct 557 ms 15296 KB Output is correct
45 Correct 519 ms 15288 KB Output is correct
46 Correct 540 ms 15292 KB Output is correct
47 Correct 461 ms 11352 KB Output is correct
48 Correct 615 ms 15564 KB Output is correct
49 Correct 562 ms 15288 KB Output is correct
50 Correct 541 ms 15464 KB Output is correct
51 Correct 260 ms 9560 KB Output is correct
52 Correct 546 ms 9816 KB Output is correct
53 Correct 525 ms 9816 KB Output is correct
54 Correct 489 ms 9816 KB Output is correct
55 Correct 575 ms 19140 KB Output is correct
56 Correct 607 ms 19020 KB Output is correct
57 Correct 595 ms 19016 KB Output is correct
58 Correct 486 ms 19012 KB Output is correct
59 Correct 566 ms 31740 KB Output is correct
60 Correct 574 ms 31740 KB Output is correct
61 Correct 337 ms 9560 KB Output is correct
62 Correct 483 ms 9816 KB Output is correct
63 Correct 542 ms 9816 KB Output is correct
64 Correct 514 ms 9816 KB Output is correct
65 Correct 532 ms 9816 KB Output is correct
66 Correct 518 ms 10148 KB Output is correct
67 Correct 497 ms 9816 KB Output is correct
68 Correct 507 ms 9816 KB Output is correct
69 Correct 536 ms 9560 KB Output is correct
70 Correct 512 ms 9560 KB Output is correct
71 Correct 495 ms 10328 KB Output is correct
72 Correct 526 ms 9816 KB Output is correct
73 Correct 533 ms 9816 KB Output is correct
74 Correct 501 ms 9816 KB Output is correct
75 Correct 508 ms 9560 KB Output is correct
76 Correct 518 ms 10328 KB Output is correct
77 Correct 532 ms 10600 KB Output is correct
78 Correct 495 ms 10600 KB Output is correct
79 Correct 517 ms 9816 KB Output is correct
80 Correct 501 ms 9560 KB Output is correct
81 Correct 509 ms 9932 KB Output is correct
82 Correct 531 ms 9560 KB Output is correct
83 Correct 260 ms 9560 KB Output is correct
84 Correct 525 ms 9816 KB Output is correct
85 Correct 504 ms 9816 KB Output is correct
86 Correct 526 ms 9816 KB Output is correct
87 Correct 2 ms 9560 KB Output is correct
88 Correct 360 ms 18764 KB Output is correct
89 Correct 582 ms 15444 KB Output is correct
90 Correct 582 ms 15228 KB Output is correct
91 Correct 557 ms 19224 KB Output is correct
92 Correct 603 ms 19472 KB Output is correct
93 Correct 602 ms 19260 KB Output is correct
94 Correct 614 ms 19256 KB Output is correct
95 Correct 571 ms 19260 KB Output is correct
96 Correct 511 ms 14832 KB Output is correct
97 Correct 559 ms 14032 KB Output is correct
98 Correct 550 ms 27968 KB Output is correct
99 Correct 613 ms 19020 KB Output is correct
100 Incorrect 597 ms 17284 KB 119th lines differ - on the 1st token, expected: '688149308', found: '513157708'
101 Halted 0 ms 0 KB -