QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#400457#4900. 数列重排zslizeyu15 453ms8800kbC++142.3kb2024-04-27 11:58:592024-04-27 11:58:59

Judging History

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

  • [2024-04-27 11:58:59]
  • 评测
  • 测评结果:15
  • 用时:453ms
  • 内存:8800kb
  • [2024-04-27 11:58:59]
  • 提交

answer

#include<bits/stdc++.h>
#define fo(i,x,y) for(int i(x);i<=y;i=-~i)
#define fd(i,x,y) for(int i(x);i>=y;--i)
#define ll long long
using namespace std;

const int M=1e7+5,mo=998244353,base=233;

int m,l,r,X,n,pw[M],ans;
char s[M];

int read(){
    char ch(getchar());int nu(0),w(0);
    while(ch<48||ch>57){
        if(ch=='-')w=1;ch=getchar();
    }
    while(ch>=48&&ch<=57){
        nu=(nu<<1)+(nu<<3)+(ch^48);ch=getchar();
    }
    if(w)nu=-nu;
    return nu;
}

namespace task1{
    int a[105],b[105],c[105],f[105];
    bool vis[105],v[105];

    void dfs(int x){
        if(x>n){
            fo(i,0,m)c[i]=0;
            fo(l,1,n){
                fo(i,0,m-1)v[i]=false;
                int now(0);
                fo(r,l,n){
                    v[b[r]]=true;while(v[now])++now;++c[now];
                }
            }
            fd(i,m-1,0)c[i]+=c[i+1];
            fo(i,0,m)f[i]=max(f[i],c[i]);
            return;
        }
        fo(i,1,n)
        if(!vis[i]){
            b[x]=a[i];vis[i]=true;
            dfs(x+1);
            vis[i]=false;
        }
    }
    void solve(){
        fo(i,0,m-1){
            int cnt=s[i]^48?X+1:X;while(cnt--)a[++n]=i;
        }
        dfs(1);
        fo(i,l,r)ans^=1ll*f[i]*pw[i]%mo;
        printf("%d\n",ans);
    }
}

namespace task2{
    void solve(){
        int cnt(0);fo(i,0,m-1)if(s[i]^48)++cnt;
        n=m*X+cnt;
        ll tot=1ll*n*(n+1)>>1;
        ans^=tot%mo;
        if(m>1)tot-=s[1]^48?X+1:X;
        ans^=tot%mo*base%mo;
        printf("%d\n",ans);
    }
}

namespace task3{
    void solve(){
        fo(i,l,r){
            int x=(n-i+2)>>1;
            //printf("%d %d\n",i,1ll*x*(n-i+2-x));
            int res(0);
            if(i)res=1ll*x*(n-i+2-x)%mo*pw[i]%mo;
            else res=(1ll*n*(n+1)>>1)%mo;
            ans^=res;
        }
        printf("%d\n",ans);
    }
}

bool js3(){
    int cnt(0);fo(i,0,m-1)if(s[i]^48)++cnt;
    n=m*X+cnt;
    return n==m;
}
void solve(){
    if(m<=2&&l==0&&r==1){
        task2::solve();return;
    }
    if(js3()){
        task3::solve();return;
    }
    task1::solve();
}

int main(){
    m=read();l=read();r=read();X=read();
    pw[0]=1;fo(i,1,m)pw[i]=1ll*pw[i-1]*base%mo;
    scanf("%s",s);
    solve();
    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: 453ms
memory: 3780kb

input:

2 0 2 2
01

output:

2287017

result:

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

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: 3820kb

input:

2 0 1 114514
10

output:

934764137

result:

ok 1 number(s): "934764137"

Test #15:

score: 5
Accepted
time: 0ms
memory: 3956kb

input:

2 0 1 1919810
01

output:

685371514

result:

ok 1 number(s): "685371514"

Test #16:

score: 5
Accepted
time: 0ms
memory: 3928kb

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: 10
Accepted

Test #19:

score: 10
Accepted
time: 11ms
memory: 8800kb

input:

1000000 0 1000000 1
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

852768823

result:

ok 1 number(s): "852768823"

Test #20:

score: 10
Accepted
time: 12ms
memory: 8720kb

input:

1000000 0 1000000 1
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

852768823

result:

ok 1 number(s): "852768823"

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%