QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#360819 | #4900. 数列重排 | dengtingyu | 35 | 13ms | 13980kb | C++20 | 1.1kb | 2024-03-22 10:41:39 | 2024-03-22 10:41:40 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define yu (998244353)
#define bas (233)
#define N 10001000
ll m,l,r,x;string s;ll ji[N];
ll k,n;
inline ll gt(ll x){return x*(x+1)/2;}
inline ll gt1(ll x){return x*(k-1)+gt(x/2)+gt((x+1)/2);}
inline ll gt2(ll x,ll y){if(!y)return 0;ll tem=(x/y),res=x%y;return x*(2*k-2)+gt(tem)*y+res*(tem+1);}
inline ll suan(ll a,ll b,ll nk){
k=nk;if(!k)return n*(n+1)/2;
ll an=n*(n+1)/2-k*(k-1)/2-(k-1)*(a-k+1);//cout<<a<<' '<<b<<' '<<k<<' '<<an<<'\n';
ll z=a/k+1,g=min(b,2*k-2);ll tt=b-g,tem=(tt/z),res=tt%z;
ll u=g+tem*2+min(2ll,res),v=b-u;ll pre=an;
an-=gt1(u);an-=gt2(v,z-2);
// cout<<a<<' '<<b<<' '<<k<<' '<<an<<'\n';
return an;
}
int main(){
// freopen("test1.in","r",stdin);
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
cin>>m>>l>>r>>x>>s;ll b=x*m;for(int i=0;i<m;i++)ji[i]=s[i]-'0',b+=ji[i];n=b;
ll ans=0,tem=1,a=0;for(int i=0;i<l;i++)a+=x+ji[i],b-=x+ji[i],tem=tem*bas%yu;
for(int i=l;i<=r;i++){
ans^=suan(a,b,i)*tem%yu;
a+=x+ji[i],b-=x+ji[i];tem=tem*bas%yu;
}cout<<ans;return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 0ms
memory: 3724kb
input:
2 0 2 2 01
output:
541257
result:
ok 1 number(s): "541257"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
4 1 4 2 00001
output:
525797597
result:
ok 1 number(s): "525797597"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
9 0 9 1 000000000
output:
711136343
result:
ok 1 number(s): "711136343"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
1 0 1 9 0
output:
10456
result:
ok 1 number(s): "10456"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
2 1 2 3 11
output:
1518844
result:
ok 1 number(s): "1518844"
Subtask #2:
score: 15
Accepted
Dependency #1:
100%
Accepted
Test #6:
score: 15
Accepted
time: 0ms
memory: 3660kb
input:
21 0 21 9 111010011100100100000
output:
171658329
result:
ok 1 number(s): "171658329"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
200 0 200 1 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
output:
287932632
result:
ok 1 number(s): "287932632"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
120 3 119 1 101000110101001100011100001011101110101010000011101110010101101000111100111100001001010010110001110011001010110001101111
output:
856785458
result:
ok 1 number(s): "856785458"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
2 0 2 99 10
output:
67513337
result:
ok 1 number(s): "67513337"
Subtask #3:
score: 15
Accepted
Dependency #2:
100%
Accepted
Test #10:
score: 15
Accepted
time: 0ms
memory: 3692kb
input:
10 1 9 499 0110011010
output:
47418354
result:
ok 1 number(s): "47418354"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
100 0 100 49 1100100011111101111111001000000100010000101010110000011011110100100011111000111101100010001000001100
output:
100314042
result:
ok 1 number(s): "100314042"
Test #12:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
1000 0 1000 4 1011110001101000100110000111011110101100110011100010001100001101000111100011100011110101000010000100101011010110000110100011011010011000111100100100100001000011001000000000111001010001000000110001001011100010011101010011011110001101000010010000101000100001111101001100100001010010001100...
output:
738329201
result:
ok 1 number(s): "738329201"
Test #13:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
5000 0 5000 1 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
76076468
result:
ok 1 number(s): "76076468"
Subtask #4:
score: 0
Wrong Answer
Test #14:
score: 5
Accepted
time: 0ms
memory: 3608kb
input:
2 0 1 114514 10
output:
934764137
result:
ok 1 number(s): "934764137"
Test #15:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
2 0 1 1919810 01
output:
685371514
result:
ok 1 number(s): "685371514"
Test #16:
score: -5
Wrong Answer
time: 0ms
memory: 3684kb
input:
2 0 1 500000000 00
output:
178411081
result:
wrong answer 1st numbers differ - expected: '318651831', found: '178411081'
Subtask #5:
score: 0
Wrong Answer
Test #17:
score: 0
Wrong Answer
time: 3ms
memory: 12548kb
input:
1000000 1000000 1000000 928 01100010010000000101111110001111011101111000011110100101011110011001001000011000110101101100111110000100101010111001111100010011100110000000111110110100001100000000011101100001010001010000010000001001000110011111010101111100001001110110010100000011000010010001111010011100...
output:
483549410
result:
wrong answer 1st numbers differ - expected: '437299311', found: '483549410'
Subtask #6:
score: 0
Wrong Answer
Test #19:
score: 0
Wrong Answer
time: 13ms
memory: 13972kb
input:
1000000 0 1000000 1 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
684414961
result:
wrong answer 1st numbers differ - expected: '852768823', found: '684414961'
Subtask #7:
score: 0
Wrong Answer
Test #21:
score: 0
Wrong Answer
time: 3ms
memory: 13980kb
input:
1000000 0 9823 627 01110001011101001100010011100101001011000011011110001101010000000101010111110111110010010001110100101001111000111100011101111001000000100111000010010100010101110110111110100010101010001110111001100011010001111000101010000110010010101110101010111110110001110111111000001110000110011...
output:
-257264243
result:
wrong answer 1st numbers differ - expected: '383638431', found: '-257264243'
Subtask #8:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Dependency #4:
0%
Subtask #9:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Dependency #4:
0%