QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#227345#6621. Luggage Lockwhsyhyyh#WA 2ms9744kbC++14885b2023-10-27 12:48:532023-10-27 12:48:54

Judging History

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

  • [2023-10-27 12:48:54]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:9744kb
  • [2023-10-27 12:48:53]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N = 2e6+9;
int n,nxt[N],mn[N],len[N];
char s[N];


int main(){
    scanf("%s",s+1);
    n=strlen(s+1);s[n+1]='#';
    for(int i=1;i<=n;i++) s[i+n+1]=s[i];
    nxt[0]=-1,mn[0]=N;
    int l=n+2;
    for(int i=1;i<=n*2+1;i++){
        int j=i-1;mn[i]=N;
        // printf("%d\n",i);
        while(nxt[j]!=-1&&s[nxt[j]+1]!=s[i]){
            j=nxt[j];
            // printf("%d\n",j);
            mn[i]=min(mn[i],(int)s[j+1]);
        }
        nxt[i]=nxt[j]+1;
        if(i==n+2) len[i]=1;
        else if(i>n+2){
            int k=len[i-1];
            while(mn[k]<(int)s[i]){
                k=nxt[k];
            }
            len[i]=k+1;
        }
        if(i>=n+2){
            int r=i-n-1;
            int l=r-len[i]+1;
            printf("%d %d\n",l,r);
        }
    }   
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 9744kb

input:

6
1234 2345
1234 0123
1234 2267
1234 3401
1234 1344
1234 2468

output:

1 1

result:

wrong answer Answer contains longer sequence [length = 6], but output contains 2 elements