QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#243741 | #4900. 数列重排 | Graygoo | 5 | 3ms | 7468kb | C++14 | 1.5kb | 2023-11-08 16:32:39 | 2023-11-08 16:32:40 |
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 998244353
int n,m;
int l,r,x;
char s[500001];
int pw[500001];
namespace solve01{
void solve(){
int ans0=n*(n+1)/2;
int ans1=ans0;
int num=x+s[0]-'0';
int rt=(n-num)/num;
int o2=rt?(n-num)%rt:n-num;int o1=n-num-o2*(rt+1);
ans1-=o2*((rt+1)*(rt+2)/2)+o1*(rt*(rt+1)/2);
ans1%=mod;ans0%=mod;
int ans=ans0 ^ (ans1*pw[1]%mod);
cout<<ans<<endl;
return ;
}
}
namespace solvem{
void solve(){
int ans=(n-m+2)*(n-m+1)/2;
ans%=mod;
cout<<ans*pw[m]%mod<<endl;
return ;
}
}
namespace btf{
int o[11];
int ptr=0;
int ans[11];
int ss[11];
int cnt[11];
void check(){
int ptr=0;memset(ss,0,sizeof(ss));
for(int i=1;i<=n;i++){
memset(cnt,0,sizeof(cnt));ptr=0;
for(int j=i;j<=n;j++){
cnt[o[j]]++;
while(cnt[ptr])ptr++;
ss[ptr]++;
}
}
for(int i=m-1;i>=0;i--)ss[i]=(ss[i]+ss[i+1])%mod;
for(int i=0;i<m;i++)ans[i]=max(ans[i],ss[i]);
return ;
}
void solve(){
memset(ans,0,sizeof(ans));
for(int i=0;i<m;i++){
for(int j=1;j<=x+s[i]-'0';j++){
o[++ptr]=i;
}
}
check();
while(next_permutation(o+1,o+n+1))check();
int an=0;
for(int i=l;i<=r;i++)an=an^ (ans[i]*pw[i]%mod);
cout<<an<<endl;
return ;
}
}
signed main(){
pw[0]=1;
for(int i=1;i<=500000;i++)pw[i]=pw[i-1]*233%mod;
cin>>m>>l>>r>>x;n=m*x;
for(int i=0;i<m;i++){cin>>s[i];n+=s[i]-'0';}
if(n<=9)btf::solve();
else if(l==0 and r==1)solve01::solve();
else if(l==m and r==m)solvem::solve();
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 7468kb
input:
2 0 2 2 01
output:
2787
result:
wrong answer 1st numbers differ - expected: '541257', found: '2787'
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: 3ms
memory: 7312kb
input:
2 0 1 114514 10
output:
934764137
result:
ok 1 number(s): "934764137"
Test #15:
score: 0
Accepted
time: 0ms
memory: 7468kb
input:
2 0 1 1919810 01
output:
685371514
result:
ok 1 number(s): "685371514"
Test #16:
score: 0
Accepted
time: 0ms
memory: 7252kb
input:
2 0 1 500000000 00
output:
318651831
result:
ok 1 number(s): "318651831"
Subtask #5:
score: 0
Runtime Error
Test #17:
score: 0
Runtime Error
input:
1000000 1000000 1000000 928 01100010010000000101111110001111011101111000011110100101011110011001001000011000110101101100111110000100101010111001111100010011100110000000111110110100001100000000011101100001010001010000010000001001000110011111010101111100001001110110010100000011000010010001111010011100...
output:
result:
Subtask #6:
score: 0
Runtime Error
Test #19:
score: 0
Runtime Error
input:
1000000 0 1000000 1 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
result:
Subtask #7:
score: 0
Runtime Error
Test #21:
score: 0
Runtime Error
input:
1000000 0 9823 627 01110001011101001100010011100101001011000011011110001101010000000101010111110111110010010001110100101001111000111100011101111001000000100111000010010100010101110110111110100010101010001110111001100011010001111000101010000110010010101110101010111110110001110111111000001110000110011...
output:
result:
Subtask #8:
score: 0
Skipped
Dependency #1:
0%
Subtask #9:
score: 0
Skipped
Dependency #1:
0%