#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[K]-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;
void dfs(int u,int d=1){
if(u>n)mul[u-n]=pw[n+m-d];
for(auto v:adj[u])dfs(v,d+1);
}
void init(int N, int M, std::vector<int> P, std::vector<int> A) {
n=N,m=M;
pw[0]=1;
for(int i=1;i<=n+m;i++)pw[i]=pw[i-1]*2%mod;
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);
}
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:75:6: warning: unused variable 'cur' [-Wunused-variable]
75 | int cur=1;
| ^~~
circuit.cpp: In member function 'void segtree::update(int, int, int, int, int)':
circuit.cpp:24:18: warning: array subscript 262144 is above array bounds of 'll [262144]' {aka 'long long int [262144]'} [-Warray-bounds]
24 | t[i]=(mod+all[K]-t[i])%mod;
| ~~~~~^
circuit.cpp:20:10: note: while referencing 'segtree::all'
20 | ll t[K],all[K];
| ^~~
circuit.cpp:24:18: warning: array subscript 262144 is above array bounds of 'll [262144]' {aka 'long long int [262144]'} [-Warray-bounds]
24 | t[i]=(mod+all[K]-t[i])%mod;
| ~~~~~^
circuit.cpp:20:10: note: while referencing 'segtree::all'
20 | ll t[K],all[K];
| ^~~
circuit.cpp: In function 'int count_ways(int, int)':
circuit.cpp:24:18: warning: array subscript 262144 is above array bounds of 'll [262144]' {aka 'long long int [262144]'} [-Warray-bounds]
24 | t[i]=(mod+all[K]-t[i])%mod;
| ~~~~~^
circuit.cpp:20:10: note: while referencing 'segtree::all'
20 | ll t[K],all[K];
| ^~~
circuit.cpp:58:2: note: defined here 's'
58 | }s;
| ^
circuit.cpp:24:18: warning: array subscript 262144 is above array bounds of 'll [262144]' {aka 'long long int [262144]'} [-Warray-bounds]
24 | t[i]=(mod+all[K]-t[i])%mod;
| ~~~~~^
circuit.cpp:20:10: note: while referencing 'segtree::all'
20 | ll t[K],all[K];
| ^~~
circuit.cpp:58:2: note: defined here 's'
58 | }s;
| ^
circuit.cpp:24:18: warning: array subscript 262144 is above array bounds of 'll [262144]' {aka 'long long int [262144]'} [-Warray-bounds]
24 | t[i]=(mod+all[K]-t[i])%mod;
| ~~~~~^
circuit.cpp:20:10: note: while referencing 'segtree::all'
20 | ll t[K],all[K];
| ^~~
circuit.cpp:58:2: note: defined here 's'
58 | }s;
| ^
circuit.cpp:24:18: warning: array subscript 262144 is above array bounds of 'll [262144]' {aka 'long long int [262144]'} [-Warray-bounds]
24 | t[i]=(mod+all[K]-t[i])%mod;
| ~~~~~^
circuit.cpp:20:10: note: while referencing 'segtree::all'
20 | ll t[K],all[K];
| ^~~
circuit.cpp:58:2: note: defined here 's'
58 | }s;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2640 KB |
1st lines differ - on the 1st token, expected: '1', found: '65536' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2640 KB |
1st lines differ - on the 1st token, expected: '1', found: '65536' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2640 KB |
1st lines differ - on the 1st token, expected: '1', found: '65536' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
465 ms |
6352 KB |
1st lines differ - on the 1st token, expected: '431985922', found: '545337854' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
465 ms |
6352 KB |
1st lines differ - on the 1st token, expected: '431985922', found: '545337854' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2640 KB |
1st lines differ - on the 1st token, expected: '1', found: '65536' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2640 KB |
1st lines differ - on the 1st token, expected: '1', found: '65536' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2640 KB |
1st lines differ - on the 1st token, expected: '1', found: '65536' |
2 |
Halted |
0 ms |
0 KB |
- |