QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#400829 | #4900. 数列重排 | 2020zym | 15 | 12ms | 20316kb | C++14 | 2.0kb | 2024-04-27 16:43:57 | 2024-04-27 16:43:57 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int MOD=998244353;
char s[10000010];
long long Ans[10000111],n;
int zan[10000010],cun[10000010],m,l,r,x,buf[10000010],ji1[10000011];
void dfs(int x){
if(x>n){
for(int i=0;i<=m;i++)ji1[i]=0;
for(int i=1;i<=n;i++){
int op=0;
for(int j=0;j<=m-1;j++)buf[j]=0;
for(int j=i;j<=n;j++){
buf[zan[j]]=1;
while(buf[op])op++;
ji1[op]++;
}
}
for(int i=m-1;i>=0;i--)ji1[i]+=ji1[i+1];
for(int i=0;i<=m;i++)Ans[i]=max(Ans[i],(long long)ji1[i]);
return;
}
for(int i=0;i<=m-1;i++){
if(cun[i]){
zan[x]=i;
cun[i]--;
dfs(x+1);
cun[i]++;
zan[x]=0;
}
}
}
long long ksm(long long x,long long y){
long long ans=1;
while(y){
if(y&1)ans=ans*x%MOD;
x=x*x%MOD,y>>=1;
}
return ans;
}
int main(){
// freopen("mex.in","r",stdin);
// freopen("mex.out","w",stdout);
scanf("%d%d%d%d",&m,&l,&r,&x);
scanf("%s",s);
for(int i=0;i<=m-1;i++)cun[i]=x+(s[i]=='1'),n+=cun[i];
if(n<=0){
dfs(1);
int op=1;
long long ans=0;
for(int i=0;i<=r;i++){
if(i>=l)ans^=(op*1ll*Ans[i]%MOD);
op=op*233ll%MOD;
}
printf("%lld\n",ans);
}
else{
if(l==m&&r==m){
int minn=0x3f3f3f3f;
for(int i=0;i<=m-1;i++)minn=min(minn,cun[i]);
int l1=0,l2=0;
for(int i=0;i<=m-1;i++){
if(cun[i]==minn)break;
l1++;
}
for(int i=m-1;i>=0;i--){
if(cun[i]==minn)break;
l2++;
}
printf("%lld\n",(minn*1ll*m+l1+l2-m+1)%MOD*ksm(233,m)%MOD);
return 0;
}
if(m<=2&&l==0&&r==1){
Ans[1]=(n*1ll*(n+1)/2-cun[1])%MOD;
Ans[0]=(n*1ll*(n+1)/2)%MOD;
printf("%lld\n",(Ans[0])^(Ans[1]*233%MOD));
return 0;
}
if(x==1){
Ans[0]=(n*1ll*(n+1)/2)%MOD;
for(int i=1;i<=m;i++){
long long op=m-i,op2=op/2;
Ans[i]=(op2+1)*(op-op2+1)%MOD;
}
long long op=1;
long long ans=0;
for(int i=0;i<=r;i++){
if(i>=l)ans^=(op*1ll*Ans[i]%MOD);
op=op*233ll%MOD;
}
printf("%lld\n",ans);
return 0;
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 7812kb
input:
2 0 2 2 01
output:
result:
wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 5
Accepted
Test #14:
score: 5
Accepted
time: 0ms
memory: 8044kb
input:
2 0 1 114514 10
output:
934764137
result:
ok 1 number(s): "934764137"
Test #15:
score: 0
Accepted
time: 1ms
memory: 7920kb
input:
2 0 1 1919810 01
output:
685371514
result:
ok 1 number(s): "685371514"
Test #16:
score: 0
Accepted
time: 0ms
memory: 8048kb
input:
2 0 1 500000000 00
output:
318651831
result:
ok 1 number(s): "318651831"
Subtask #5:
score: 0
Wrong Answer
Test #17:
score: 0
Wrong Answer
time: 5ms
memory: 12136kb
input:
1000000 1000000 1000000 928 01100010010000000101111110001111011101111000011110100101011110011001001000011000110101101100111110000100101010111001111100010011100110000000111110110100001100000000011101100001010001010000010000001001000110011111010101111100001001110110010100000011000010010001111010011100...
output:
285149273
result:
wrong answer 1st numbers differ - expected: '437299311', found: '285149273'
Subtask #6:
score: 10
Accepted
Test #19:
score: 10
Accepted
time: 12ms
memory: 20012kb
input:
1000000 0 1000000 1 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
852768823
result:
ok 1 number(s): "852768823"
Test #20:
score: 0
Accepted
time: 8ms
memory: 20316kb
input:
1000000 0 1000000 1 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
852768823
result:
ok 1 number(s): "852768823"
Subtask #7:
score: 0
Wrong Answer
Test #21:
score: 0
Wrong Answer
time: 4ms
memory: 11960kb
input:
1000000 0 9823 627 01110001011101001100010011100101001011000011011110001101010000000101010111110111110010010001110100101001111000111100011101111001000000100111000010010100010101110110111110100010101010001110111001100011010001111000101010000110010010101110101010111110110001110111111000001110000110011...
output:
result:
wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements
Subtask #8:
score: 0
Skipped
Dependency #1:
0%
Subtask #9:
score: 0
Skipped
Dependency #1:
0%