QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#360821#4900. 数列重排dengtingyu0 1ms4036kbC++201.1kb2024-03-22 10:44:412024-03-22 10:44:42

Judging History

你现在查看的是最新测评结果

  • [2024-03-22 10:44:42]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:4036kb
  • [2024-03-22 10:44:41]
  • 提交

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<<' '<<pre<<'\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)%yu*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: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3916kb

input:

2 0 2 2
01

output:

0

result:

wrong answer 1st numbers differ - expected: '541257', found: '0'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Wrong Answer

Test #14:

score: 0
Wrong Answer
time: 0ms
memory: 3988kb

input:

2 0 1 114514
10

output:

0

result:

wrong answer 1st numbers differ - expected: '934764137', found: '0'

Subtask #5:

score: 0
Wrong Answer

Test #17:

score: 0
Wrong Answer
time: 1ms
memory: 4036kb

input:

1000000 1000000 1000000 928
01100010010000000101111110001111011101111000011110100101011110011001001000011000110101101100111110000100101010111001111100010011100110000000111110110100001100000000011101100001010001010000010000001001000110011111010101111100001001110110010100000011000010010001111010011100...

output:

0

result:

wrong answer 1st numbers differ - expected: '437299311', found: '0'

Subtask #6:

score: 0
Wrong Answer

Test #19:

score: 0
Wrong Answer
time: 1ms
memory: 3984kb

input:

1000000 0 1000000 1
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

0

result:

wrong answer 1st numbers differ - expected: '852768823', found: '0'

Subtask #7:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 0ms
memory: 3984kb

input:

1000000 0 9823 627
01110001011101001100010011100101001011000011011110001101010000000101010111110111110010010001110100101001111000111100011101111001000000100111000010010100010101110110111110100010101010001110111001100011010001111000101010000110010010101110101010111110110001110111111000001110000110011...

output:

0

result:

wrong answer 1st numbers differ - expected: '383638431', found: '0'

Subtask #8:

score: 0
Skipped

Dependency #1:

0%

Subtask #9:

score: 0
Skipped

Dependency #1:

0%