QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#429791#5981. Costly Binary SearchBronya0 23781ms82900kbC++141.1kb2024-06-02 20:53:392024-06-02 20:53:39

Judging History

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

  • [2024-06-02 20:53:39]
  • 评测
  • 测评结果:0
  • 用时:23781ms
  • 内存:82900kb
  • [2024-06-02 20:53:39]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;
int T;
char s[1000005];
int L[10][1000005],R[10][1000005];
int now,n;
int main(){
    scanf("%d",&T);
    int tid=0;
    while(T--){
        scanf("%s",s+1);n=strlen(s+1);
        for(int i=0;i<=9;i++)
            for(int j=0;j<=n+1;j++)
                L[i][j]=j+1,R[i][j]=j-1;
        for(int i=1;i<=n;i++)L[s[i]-'0'][i]=R[s[i]-'0'][i]=i;
        for(int i=0;i<=180;i++){
            int x=i%10;
            if(R[x][1]==n){
                printf("Case #%d: %d\n",++tid,i);
                break;
            }
            int y=(x+9)%10,l=0,r=0;
            if(i)for(int j=1;j<=n;j++)L[x][j]=min(L[y][j],L[x][j]),R[x][j]=max(R[x][j],R[y][j]);
            for(int i=1;i<=n;i++)L[x][i]=max(L[x][i],L[x][i-1]);
            for(int i=n-1;i>=1;i--)R[x][i]=min(R[x][i],R[x][i+1]);
            for(int i=1;i<=n;i++){
                y=(x+s[i]-'0')%10;
                l=L[x][i-1];r=R[x][i+1];
                R[y][l]=max(R[y][l],r);
                L[y][r]=min(L[y][r],l);
            }
        }
    }
    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: 205ms
memory: 42776kb

input:

50
8
5128831164925953487661279378526736416489768154389124821528467927357884749642747626797857463132866343496157991453139582295398452863172464853698678624523849653538713928372648295734165346972222781179687541337591976277864785653638476127839556323849395641196246971351933655287441377531627938395427487...

output:

Case #1: 8
Case #2: 126
Case #3: 117
Case #4: 15
Case #5: 14
Case #6: 9
Case #7: 126
Case #8: 117
Case #9: 1
Case #10: 3
Case #11: 126
Case #12: 15
Case #13: 84

result:

wrong answer 2nd lines differ - expected: 'Case #2: 37', found: 'Case #2: 126'

Subtask #2:

score: 0
Wrong Answer

Test #2:

score: 0
Wrong Answer
time: 23781ms
memory: 82900kb

input:

50
647322722753778843259213887674615134214258235986992692879314555957455541351526284343217116351733247781713552149464672262787737941588358671583528664757823365936975517145283412965139791726299864122725212222496898855627124979178341548651669956711341742838725446489235961853391195148929571712449139335...

output:

Case #1: 120
Case #2: 172
Case #3: 21
Case #4: 180
Case #5: 180
Case #6: 21
Case #7: 180
Case #8: 172
Case #9: 20

result:

wrong answer 1st lines differ - expected: 'Case #1: 42', found: 'Case #1: 120'