QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#290873 | #4900. 数列重排 | SoyTony | 0 | 0ms | 0kb | C++14 | 1.8kb | 2023-12-25 18:51:59 | 2023-12-25 18:51:59 |
answer
#include<bits/stdc++.h>
using namespace std;
const int maxm=1e7+10;
const int base=233;
const int mod=998244353;
inline int read(){
int x=0,w=1;char c=getchar();
while(c<'0'||c>'9'){if(c=='-')w=-1;c=getchar();}
while(c<='9'&&c>='0'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
return x*w;
}
inline int q_pow(int A,int B,int P){
int res=1;
while(B){
if(B&1) res=1ll*res*A%P;
A=1ll*A*A%P;
B>>=1;
}
return res;
}
inline int S(int L,int R){
return 1ll*(L+R)*(R-L+1)/2%mod;
}
int n,m,l,r,x;
bool chk=true;
char s[maxm];
int f[maxm];
int ans;
int main(){
freopen("mex.in","r",stdin);
freopen("mex.out","w",stdout);
m=read(),l=read(),r=read(),x=read();
scanf("%s",s);
n=m*x;
for(int i=0;i<m;++i){
if(s[i]=='1') ++n;
}
f[0]=S(1,n);
int cnt0=0,cnt1=n;
for(int i=1;i<=m;++i){
cnt0+=x,cnt1-=x;
if(s[i-1]=='1') ++cnt0,--cnt1;
else chk=false;
f[i]=(S(1,cnt0-i+1)+S(cnt0+1,n))%mod;
if(2*i-2>=cnt1){
f[i]=(f[i]+1ll*(mod-i+1)*cnt1)%mod;
f[i]=(f[i]-2ll*S(1,cnt1/2)%mod+mod)%mod;
f[i]=(f[i]-1ll*(cnt1%2)*(cnt1/2+1)%mod+mod)%mod;
}
else{
f[i]=(f[i]+1ll*(mod-i+1)*(2*i-2))%mod;
f[i]=(f[i]-2ll*S(1,i-1)%mod+mod)%mod;
f[i]=(f[i]+2ll*(mod-i+1)*(cnt1-2*i+2)%mod)%mod;
f[i]=(f[i]-1ll*(x+1+chk)*S(1,(cnt1-2*i+2)/(x+1+chk))%mod+mod)%mod;
f[i]=(f[i]-1ll*((cnt1-2*i+2)%(x+1+chk))*((cnt1-2*i+2)/(x+1+chk)+1)%mod+mod)%mod;
}
}
int pw=q_pow(base,l,mod);
for(int i=l;i<=r;++i){
ans^=1ll*pw*f[i]%mod;
pw=1ll*pw*base%mod;
}
printf("%d\n",ans);
return 0;
}
详细
Subtask #1:
score: 0
Dangerous Syscalls
Test #1:
score: 0
Dangerous Syscalls
input:
2 0 2 2 01
output:
result:
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Dangerous Syscalls
Test #14:
score: 0
Dangerous Syscalls
input:
2 0 1 114514 10
output:
result:
Subtask #5:
score: 0
Dangerous Syscalls
Test #17:
score: 0
Dangerous Syscalls
input:
1000000 1000000 1000000 928 01100010010000000101111110001111011101111000011110100101011110011001001000011000110101101100111110000100101010111001111100010011100110000000111110110100001100000000011101100001010001010000010000001001000110011111010101111100001001110110010100000011000010010001111010011100...
output:
result:
Subtask #6:
score: 0
Dangerous Syscalls
Test #19:
score: 0
Dangerous Syscalls
input:
1000000 0 1000000 1 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
result:
Subtask #7:
score: 0
Dangerous Syscalls
Test #21:
score: 0
Dangerous Syscalls
input:
1000000 0 9823 627 01110001011101001100010011100101001011000011011110001101010000000101010111110111110010010001110100101001111000111100011101111001000000100111000010010100010101110110111110100010101010001110111001100011010001111000101010000110010010101110101010111110110001110111111000001110000110011...
output:
result:
Subtask #8:
score: 0
Skipped
Dependency #1:
0%
Subtask #9:
score: 0
Skipped
Dependency #1:
0%