提交记录 17643
| 提交时间 |
评测时间 |
| 2022-04-13 10:41:50 |
2022-04-13 10:41:55 |
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
const int N=2000010;
int tax[N],x[N],y[N],n,m,num,sa[N],rk[N],h[N];
char S[N];
void suffix_sort() {
m=256;
for(int i=1;i<=n;++i)++tax[x[i]=S[i]];
for(int i=2;i<=m;++i)tax[i]+=tax[i-1];
for(int i=1;i<=n;++i)sa[tax[x[i]]--]=i;
for(int k=1;k<=n;k<<=1) {
num=0;
for(int i=n-k+1;i<=n;++i)y[++num]=i;
for(int i=1;i<=n;++i)if(sa[i]>k)y[++num]=sa[i]-k;
for(int i=1;i<=m;++i)tax[i]=0;
for(int i=1;i<=n;++i)++tax[x[i]];
for(int i=2;i<=m;++i)tax[i]+=tax[i-1];
for(int i=n;i>=1;--i)sa[tax[x[y[i]]]--]=y[i],y[i]=0;
num=1;
swap(x,y);x[sa[1]]=1;
for(int i=2;i<=n;++i)
x[sa[i]]=(y[sa[i]]==y[sa[i-1]]&&y[sa[i]+k]==y[sa[i-1]+k])?num:++num;
if(num==n)break;
m=num;
}
for(int i=1;i<=n;++i)rk[sa[i]]=i;
for(int i=1,j;i<=n;++i) {
j=h[rk[i-1]]-1;
if(j<0)j=0;
while(S[i+j]==S[sa[rk[i]-1]+j])++j;
h[rk[i]]=j;
}
}
int main() {
scanf("%s",S+1);
n=strlen(S+1);
suffix_sort();
for(int i=1;i<=n;++i)printf("%d ",sa[i]);
for(int i=2;i<=n;++i)printf("%d ",h[i]);
return 0;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Subtask #1 Testcase #1 | 3.088 ms | 15 MB + 320 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #2 | 3.09 ms | 15 MB + 320 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #3 | 3.09 ms | 15 MB + 320 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #4 | 5.932 ms | 15 MB + 320 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #5 | 5.934 ms | 15 MB + 320 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #6 | 5.932 ms | 15 MB + 320 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #7 | 35.82 ms | 17 MB + 664 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #8 | 70.784 ms | 17 MB + 884 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #9 | 40.839 ms | 17 MB + 752 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #10 | 29.563 ms | 16 MB + 908 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #11 | 31.732 ms | 16 MB + 948 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #12 | 63.498 ms | 17 MB + 948 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #13 | 59.397 ms | 17 MB + 968 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #14 | 44.988 ms | 17 MB + 780 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #15 | 44.632 ms | 17 MB + 784 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #16 | 62.285 ms | 17 MB + 948 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #17 | 62.073 ms | 17 MB + 948 KB | Wrong Answer | Score: 0 | 显示更多 |
| Subtask #1 Testcase #18 | 62.353 ms | 17 MB + 948 KB | Wrong Answer | Score: 0 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2026-03-17 05:19:51 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠