0%

2025牛客暑期多校训练营2——Another Day of Sun(01串)

思路讲解

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
	ll t=binpow(2,tmp,mod),tt=binpow(2,mod-2,mod),tttt=binpow(4,mod-2,mod);
ll ans=0;
A[0]=0;
FOR(i,0,N-1){
if(A[i]==0 && A[i+1]==1){
ans+=t;
ans%=mod;
}else if(A[i]==-1 && A[i+1]==-1){
ans+=t*tttt;
ans%=mod;
}else if(A[i]==0 && A[i+1]==-1){
ans+=t*tt;
ans%=mod;
}else if(A[i]==-1 && A[i+1]==1){
ans+=t*tt;
ans%=mod;
}
#ifdef LOCAL
debug(i);debug(ans);
#endif
}

AC代码

https://ac.nowcoder.com/acm/contest/view-submission?submissionId=78289781

心路历程(WA,TLE,MLE……)