답안 #825693

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
825693 2023-08-15T07:07:38 Z ttamx 디지털 회로 (IOI22_circuit) C++17
100 / 100
1062 ms 23800 KB
#include "circuit.h"
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N=1e5+5;
const int M=2e5+5;
const int K=1<<18;
const ll mod=1e9+2022;

int n,m;
int a[N];
ll pw[M];
ll mul[N];
vector<int> adj[N];

struct segtree{
	ll t[K],all[K];
	bool lz[K];
	void pushlz(int l,int r,int i){
		if(!lz[i])return;
		t[i]=(mod+all[i]-t[i])%mod;
		if(l<r){
			lz[i*2]^=true;
			lz[i*2+1]^=true;
		}
		lz[i]=false;
	}
	void build(int l,int r,int i){
		if(l==r){
			t[i]=a[l]*mul[l];
			all[i]=mul[l];
			return;
		}
		int m=(l+r)/2;
		build(l,m,i*2);
		build(m+1,r,i*2+1);
		t[i]=(t[i*2]+t[i*2+1])%mod;
		all[i]=(all[i*2]+all[i*2+1])%mod;
	}
	void build(){
		build(1,m,1);
	}
	void update(int l,int r,int i,int x,int y){
		pushlz(l,r,i);
		if(y<l||r<x)return;
		if(x<=l&&r<=y)return lz[i]=true,pushlz(l,r,i),void();
		int m=(l+r)/2;
		update(l,m,i*2,x,y);
		update(m+1,r,i*2+1,x,y);
		t[i]=(t[i*2]+t[i*2+1])%mod;
	}
	void update(int x,int y){
		update(1,m,1,x,y);
	}
}s;

struct segtree2{
	ll t[K];
	void build(int l,int r,int i){
		if(l==r)return void(t[i]=adj[l].size());
		int m=(l+r)/2;
		build(l,m,i*2);
		build(m+1,r,i*2+1);
		t[i]=(t[i*2]*t[i*2+1])%mod;
	}
	void build(){
		build(1,n,1);
	}
	void update(int l,int r,int i,int x,int v){
		if(x<l||r<x)return;
		if(l==r)return void(t[i]=v);
		int m=(l+r)/2;
		update(l,m,i*2,x,v);
		update(m+1,r,i*2+1,x,v);
		t[i]=(t[i*2]*t[i*2+1])%mod;
	}
	void update(int x,int y){
		update(1,n,1,x,y);
	}
}s2;

void dfs(int u,int d=0){
	if(u>n)return void(mul[u-n]=s2.t[1]);
	s2.update(u,1);
	for(auto v:adj[u])dfs(v,d+1);
	s2.update(u,adj[u].size());
}

void init(int N, int M, std::vector<int> P, std::vector<int> A) {
	n=N,m=M;
	for(int i=1;i<=m;i++)a[i]=A[i-1];
	for(int i=1;i<n+m;i++){
		adj[P[i]+1].emplace_back(i+1);
	}
	s2.build();
	dfs(1);
	s.build();
	int cur=1;
}

int count_ways(int L, int R) {
	L-=n-1;
	R-=n-1;
	s.update(L,R);
	return s.t[1];
}

Compilation message

circuit.cpp: In function 'void init(int, int, std::vector<int>, std::vector<int>)':
circuit.cpp:101:6: warning: unused variable 'cur' [-Wunused-variable]
  101 |  int cur=1;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 2 ms 2640 KB Output is correct
4 Correct 1 ms 2640 KB Output is correct
5 Correct 1 ms 2640 KB Output is correct
6 Correct 1 ms 2640 KB Output is correct
7 Correct 1 ms 2640 KB Output is correct
8 Correct 1 ms 2640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 1 ms 2640 KB Output is correct
4 Correct 2 ms 2640 KB Output is correct
5 Correct 2 ms 2688 KB Output is correct
6 Correct 2 ms 2748 KB Output is correct
7 Correct 2 ms 2768 KB Output is correct
8 Correct 2 ms 2752 KB Output is correct
9 Correct 2 ms 2768 KB Output is correct
10 Correct 2 ms 2768 KB Output is correct
11 Correct 2 ms 2768 KB Output is correct
12 Correct 2 ms 2768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 2 ms 2640 KB Output is correct
4 Correct 1 ms 2640 KB Output is correct
5 Correct 1 ms 2640 KB Output is correct
6 Correct 1 ms 2640 KB Output is correct
7 Correct 1 ms 2640 KB Output is correct
8 Correct 1 ms 2640 KB Output is correct
9 Correct 1 ms 2640 KB Output is correct
10 Correct 1 ms 2640 KB Output is correct
11 Correct 1 ms 2640 KB Output is correct
12 Correct 2 ms 2640 KB Output is correct
13 Correct 2 ms 2688 KB Output is correct
14 Correct 2 ms 2748 KB Output is correct
15 Correct 2 ms 2768 KB Output is correct
16 Correct 2 ms 2752 KB Output is correct
17 Correct 2 ms 2768 KB Output is correct
18 Correct 2 ms 2768 KB Output is correct
19 Correct 2 ms 2768 KB Output is correct
20 Correct 2 ms 2768 KB Output is correct
21 Correct 2 ms 2768 KB Output is correct
22 Correct 2 ms 2640 KB Output is correct
23 Correct 1 ms 2768 KB Output is correct
24 Correct 2 ms 2768 KB Output is correct
25 Correct 2 ms 2768 KB Output is correct
26 Correct 2 ms 2768 KB Output is correct
27 Correct 2 ms 2768 KB Output is correct
28 Correct 2 ms 2768 KB Output is correct
29 Correct 1 ms 2640 KB Output is correct
30 Correct 2 ms 2640 KB Output is correct
31 Correct 2 ms 2768 KB Output is correct
32 Correct 2 ms 2768 KB Output is correct
33 Correct 2 ms 2768 KB Output is correct
34 Correct 2 ms 2640 KB Output is correct
35 Correct 1 ms 2640 KB Output is correct
36 Correct 2 ms 2768 KB Output is correct
37 Correct 2 ms 2768 KB Output is correct
38 Correct 2 ms 2768 KB Output is correct
39 Correct 2 ms 2768 KB Output is correct
40 Correct 2 ms 2640 KB Output is correct
41 Correct 2 ms 2640 KB Output is correct
42 Correct 1 ms 2640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 426 ms 6352 KB Output is correct
2 Correct 694 ms 10056 KB Output is correct
3 Correct 601 ms 10080 KB Output is correct
4 Correct 666 ms 10056 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 426 ms 6352 KB Output is correct
2 Correct 694 ms 10056 KB Output is correct
3 Correct 601 ms 10080 KB Output is correct
4 Correct 666 ms 10056 KB Output is correct
5 Correct 492 ms 6356 KB Output is correct
6 Correct 717 ms 10076 KB Output is correct
7 Correct 694 ms 10100 KB Output is correct
8 Correct 596 ms 10044 KB Output is correct
9 Correct 358 ms 2896 KB Output is correct
10 Correct 673 ms 3168 KB Output is correct
11 Correct 652 ms 3152 KB Output is correct
12 Correct 619 ms 3152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 1 ms 2640 KB Output is correct
4 Correct 2 ms 2640 KB Output is correct
5 Correct 2 ms 2688 KB Output is correct
6 Correct 2 ms 2748 KB Output is correct
7 Correct 2 ms 2768 KB Output is correct
8 Correct 2 ms 2752 KB Output is correct
9 Correct 2 ms 2768 KB Output is correct
10 Correct 2 ms 2768 KB Output is correct
11 Correct 2 ms 2768 KB Output is correct
12 Correct 2 ms 2768 KB Output is correct
13 Correct 426 ms 6352 KB Output is correct
14 Correct 694 ms 10056 KB Output is correct
15 Correct 601 ms 10080 KB Output is correct
16 Correct 666 ms 10056 KB Output is correct
17 Correct 492 ms 6356 KB Output is correct
18 Correct 717 ms 10076 KB Output is correct
19 Correct 694 ms 10100 KB Output is correct
20 Correct 596 ms 10044 KB Output is correct
21 Correct 358 ms 2896 KB Output is correct
22 Correct 673 ms 3168 KB Output is correct
23 Correct 652 ms 3152 KB Output is correct
24 Correct 619 ms 3152 KB Output is correct
25 Correct 744 ms 15324 KB Output is correct
26 Correct 772 ms 15452 KB Output is correct
27 Correct 763 ms 15456 KB Output is correct
28 Correct 600 ms 15448 KB Output is correct
29 Correct 747 ms 23340 KB Output is correct
30 Correct 728 ms 23292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 2 ms 2640 KB Output is correct
4 Correct 1 ms 2640 KB Output is correct
5 Correct 1 ms 2640 KB Output is correct
6 Correct 1 ms 2640 KB Output is correct
7 Correct 1 ms 2640 KB Output is correct
8 Correct 1 ms 2640 KB Output is correct
9 Correct 1 ms 2640 KB Output is correct
10 Correct 1 ms 2640 KB Output is correct
11 Correct 1 ms 2640 KB Output is correct
12 Correct 2 ms 2640 KB Output is correct
13 Correct 2 ms 2688 KB Output is correct
14 Correct 2 ms 2748 KB Output is correct
15 Correct 2 ms 2768 KB Output is correct
16 Correct 2 ms 2752 KB Output is correct
17 Correct 2 ms 2768 KB Output is correct
18 Correct 2 ms 2768 KB Output is correct
19 Correct 2 ms 2768 KB Output is correct
20 Correct 2 ms 2768 KB Output is correct
21 Correct 2 ms 2768 KB Output is correct
22 Correct 2 ms 2640 KB Output is correct
23 Correct 1 ms 2768 KB Output is correct
24 Correct 2 ms 2768 KB Output is correct
25 Correct 2 ms 2768 KB Output is correct
26 Correct 2 ms 2768 KB Output is correct
27 Correct 2 ms 2768 KB Output is correct
28 Correct 2 ms 2768 KB Output is correct
29 Correct 1 ms 2640 KB Output is correct
30 Correct 2 ms 2640 KB Output is correct
31 Correct 2 ms 2768 KB Output is correct
32 Correct 2 ms 2768 KB Output is correct
33 Correct 2 ms 2768 KB Output is correct
34 Correct 2 ms 2640 KB Output is correct
35 Correct 1 ms 2640 KB Output is correct
36 Correct 2 ms 2768 KB Output is correct
37 Correct 2 ms 2768 KB Output is correct
38 Correct 2 ms 2768 KB Output is correct
39 Correct 2 ms 2768 KB Output is correct
40 Correct 2 ms 2640 KB Output is correct
41 Correct 2 ms 2640 KB Output is correct
42 Correct 1 ms 2640 KB Output is correct
43 Correct 518 ms 3024 KB Output is correct
44 Correct 544 ms 3024 KB Output is correct
45 Correct 630 ms 3024 KB Output is correct
46 Correct 495 ms 3392 KB Output is correct
47 Correct 595 ms 3388 KB Output is correct
48 Correct 675 ms 3368 KB Output is correct
49 Correct 618 ms 3408 KB Output is correct
50 Correct 778 ms 3408 KB Output is correct
51 Correct 596 ms 3148 KB Output is correct
52 Correct 796 ms 3152 KB Output is correct
53 Correct 691 ms 3332 KB Output is correct
54 Correct 894 ms 3408 KB Output is correct
55 Correct 905 ms 3152 KB Output is correct
56 Correct 638 ms 3152 KB Output is correct
57 Correct 683 ms 3024 KB Output is correct
58 Correct 635 ms 3800 KB Output is correct
59 Correct 758 ms 3844 KB Output is correct
60 Correct 682 ms 3844 KB Output is correct
61 Correct 701 ms 3152 KB Output is correct
62 Correct 710 ms 3024 KB Output is correct
63 Correct 834 ms 2896 KB Output is correct
64 Correct 636 ms 3120 KB Output is correct
65 Correct 347 ms 2896 KB Output is correct
66 Correct 564 ms 3152 KB Output is correct
67 Correct 509 ms 3152 KB Output is correct
68 Correct 582 ms 3152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 2 ms 2640 KB Output is correct
4 Correct 1 ms 2640 KB Output is correct
5 Correct 1 ms 2640 KB Output is correct
6 Correct 1 ms 2640 KB Output is correct
7 Correct 1 ms 2640 KB Output is correct
8 Correct 1 ms 2640 KB Output is correct
9 Correct 1 ms 2640 KB Output is correct
10 Correct 1 ms 2640 KB Output is correct
11 Correct 1 ms 2640 KB Output is correct
12 Correct 2 ms 2640 KB Output is correct
13 Correct 2 ms 2688 KB Output is correct
14 Correct 2 ms 2748 KB Output is correct
15 Correct 2 ms 2768 KB Output is correct
16 Correct 2 ms 2752 KB Output is correct
17 Correct 2 ms 2768 KB Output is correct
18 Correct 2 ms 2768 KB Output is correct
19 Correct 2 ms 2768 KB Output is correct
20 Correct 2 ms 2768 KB Output is correct
21 Correct 2 ms 2768 KB Output is correct
22 Correct 2 ms 2640 KB Output is correct
23 Correct 1 ms 2768 KB Output is correct
24 Correct 2 ms 2768 KB Output is correct
25 Correct 2 ms 2768 KB Output is correct
26 Correct 2 ms 2768 KB Output is correct
27 Correct 2 ms 2768 KB Output is correct
28 Correct 2 ms 2768 KB Output is correct
29 Correct 1 ms 2640 KB Output is correct
30 Correct 2 ms 2640 KB Output is correct
31 Correct 2 ms 2768 KB Output is correct
32 Correct 2 ms 2768 KB Output is correct
33 Correct 2 ms 2768 KB Output is correct
34 Correct 2 ms 2640 KB Output is correct
35 Correct 1 ms 2640 KB Output is correct
36 Correct 2 ms 2768 KB Output is correct
37 Correct 2 ms 2768 KB Output is correct
38 Correct 2 ms 2768 KB Output is correct
39 Correct 2 ms 2768 KB Output is correct
40 Correct 2 ms 2640 KB Output is correct
41 Correct 2 ms 2640 KB Output is correct
42 Correct 1 ms 2640 KB Output is correct
43 Correct 426 ms 6352 KB Output is correct
44 Correct 694 ms 10056 KB Output is correct
45 Correct 601 ms 10080 KB Output is correct
46 Correct 666 ms 10056 KB Output is correct
47 Correct 492 ms 6356 KB Output is correct
48 Correct 717 ms 10076 KB Output is correct
49 Correct 694 ms 10100 KB Output is correct
50 Correct 596 ms 10044 KB Output is correct
51 Correct 358 ms 2896 KB Output is correct
52 Correct 673 ms 3168 KB Output is correct
53 Correct 652 ms 3152 KB Output is correct
54 Correct 619 ms 3152 KB Output is correct
55 Correct 744 ms 15324 KB Output is correct
56 Correct 772 ms 15452 KB Output is correct
57 Correct 763 ms 15456 KB Output is correct
58 Correct 600 ms 15448 KB Output is correct
59 Correct 747 ms 23340 KB Output is correct
60 Correct 728 ms 23292 KB Output is correct
61 Correct 518 ms 3024 KB Output is correct
62 Correct 544 ms 3024 KB Output is correct
63 Correct 630 ms 3024 KB Output is correct
64 Correct 495 ms 3392 KB Output is correct
65 Correct 595 ms 3388 KB Output is correct
66 Correct 675 ms 3368 KB Output is correct
67 Correct 618 ms 3408 KB Output is correct
68 Correct 778 ms 3408 KB Output is correct
69 Correct 596 ms 3148 KB Output is correct
70 Correct 796 ms 3152 KB Output is correct
71 Correct 691 ms 3332 KB Output is correct
72 Correct 894 ms 3408 KB Output is correct
73 Correct 905 ms 3152 KB Output is correct
74 Correct 638 ms 3152 KB Output is correct
75 Correct 683 ms 3024 KB Output is correct
76 Correct 635 ms 3800 KB Output is correct
77 Correct 758 ms 3844 KB Output is correct
78 Correct 682 ms 3844 KB Output is correct
79 Correct 701 ms 3152 KB Output is correct
80 Correct 710 ms 3024 KB Output is correct
81 Correct 834 ms 2896 KB Output is correct
82 Correct 636 ms 3120 KB Output is correct
83 Correct 347 ms 2896 KB Output is correct
84 Correct 564 ms 3152 KB Output is correct
85 Correct 509 ms 3152 KB Output is correct
86 Correct 582 ms 3152 KB Output is correct
87 Correct 1 ms 2640 KB Output is correct
88 Correct 428 ms 14712 KB Output is correct
89 Correct 696 ms 11188 KB Output is correct
90 Correct 709 ms 10976 KB Output is correct
91 Correct 679 ms 15496 KB Output is correct
92 Correct 817 ms 15564 KB Output is correct
93 Correct 904 ms 15476 KB Output is correct
94 Correct 727 ms 15452 KB Output is correct
95 Correct 892 ms 15448 KB Output is correct
96 Correct 671 ms 9968 KB Output is correct
97 Correct 828 ms 9976 KB Output is correct
98 Correct 442 ms 16408 KB Output is correct
99 Correct 1062 ms 15452 KB Output is correct
100 Correct 722 ms 12360 KB Output is correct
101 Correct 856 ms 11392 KB Output is correct
102 Correct 574 ms 9964 KB Output is correct
103 Correct 960 ms 23284 KB Output is correct
104 Correct 836 ms 23796 KB Output is correct
105 Correct 740 ms 23800 KB Output is correct
106 Correct 793 ms 12508 KB Output is correct
107 Correct 606 ms 11232 KB Output is correct
108 Correct 644 ms 10620 KB Output is correct
109 Correct 785 ms 10088 KB Output is correct