提交记录 12976
| 提交时间 |
评测时间 |
| 2020-07-16 14:09:28 |
2020-08-01 03:02:31 |
//上一份代码是假的
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1e6+11;
int x[N << 1], y[N << 1], sum[N], sa[N], ht[N];
char str[N];
void get_sa_ht(int len) {
int m=133;
for (int i = 0; i <= m; ++i) sum[i] = 0;
for (int i = 1; i <= len; ++i) ++sum[x[i] = (int)str[i]];
for (int i = 1; i <= m; ++i) sum[i] += sum[i - 1];
for (int i = len; i ; --i) sa[sum[x[i]]--] = i;
for (int h = 1; h <= len; h <<= 1) {
int yt = 0;
for(int i = len -h + 1; i <= len; ++i) y[++yt] = i;
for(int i = 1;i <= len; ++i) {
if(sa[i] - h > 0) {
y[++yt] = sa[i] - h;
}
}
for(int i = 0; i <= m; ++i) sum[i] = 0;
for(int i = 1; i <=len; ++i) ++sum[x[i]];
for(int i = 1; i <= m; ++i) sum[i] += sum[i - 1];
for(int i = len; i; --i) sa[sum[x[y[i]]]--] = y[i];
for(int i = 0; i <= len; ++i) y[i] = x[i];
x[sa[1]] = 1;
m=1;
for(int i = 2; i <= len; ++i){
if(y[sa[i]] == y[sa[i - 1]] && y[sa[i] + h] == y[sa[i - 1] + h])x[sa[i]] = m;
else x[sa[i]] = ++m;
}
if(m == len)break;
}
for(int i = 1; i <= len ; ++i) {
if(x[i] == 1)continue;
ht[x[i]] = 0;
if(i != 1 && ht[x[i - 1]] > 1)ht[x[i]] = ht[x[i - 1]] - 1;
while(str[i + ht[x[i]]] == str[sa[x[i] - 1] + ht[x[i]]] && max(i + ht[x[i]], sa[x[i] - 1] + ht[x[i]]) <= len) ++ht[x[i]];
}
}
int main() {
scanf("%s", str + 1);
int len = strlen(str + 1);
get_sa_ht(len);
for(int i = 1; i <= len; ++i) {
printf("%d ", sa[i]);
}
printf("\n");
for(int i = 2; i <= len; ++i) {
printf("%d ",ht[i]);
}
return 0;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Subtask #1 Testcase #1 | 36.24 us | 56 KB | Wrong Answer | Score: -100 | 显示更多 |
| Subtask #1 Testcase #2 | 44.62 us | 60 KB | Accepted | Score: 100 | 显示更多 |
| Subtask #1 Testcase #3 | 44.76 us | 60 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #4 | 42.51 us | 60 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #5 | 42.13 us | 60 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #6 | 40.88 us | 60 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #7 | 30.437 ms | 2 MB + 788 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #8 | 47.083 ms | 2 MB + 1008 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #9 | 32.722 ms | 2 MB + 880 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #10 | 21.22 ms | 1 MB + 904 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #11 | 21.994 ms | 1 MB + 944 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #12 | 38.358 ms | 3 MB + 48 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #13 | 37.143 ms | 3 MB + 68 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #14 | 34.045 ms | 2 MB + 904 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #15 | 33.595 ms | 2 MB + 908 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #16 | 37.151 ms | 3 MB + 48 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #17 | 36.703 ms | 3 MB + 48 KB | Accepted | Score: 0 | 显示更多 |
| Subtask #1 Testcase #18 | 37.022 ms | 3 MB + 48 KB | Accepted | Score: 0 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2026-03-25 03:13:13 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠