QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#227345 | #6621. Luggage Lock | whsyhyyh# | WA | 2ms | 9744kb | C++14 | 885b | 2023-10-27 12:48:53 | 2023-10-27 12:48:54 |
Judging History
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