mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-08 16:18:46 +00:00
parent
08dbbe056d
commit
ed2f6d2437
53
S2OJ/305/305.cpp
Normal file
53
S2OJ/305/305.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <string>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 1e6 + 5;
|
||||
|
||||
int n, sa[N];
|
||||
std::string s;
|
||||
std::array<int, N> rk, rk1;
|
||||
|
||||
void get_sa() {
|
||||
for (int i = 1; i <= n; i++) {
|
||||
sa[i] = i;
|
||||
rk[i] = s[i];
|
||||
}
|
||||
|
||||
for (int w = 1; w < n; w <<= 1) {
|
||||
std::sort(sa + 1, sa + 1 + n, [&](int x, int y) {
|
||||
return rk[x] == rk[y] ? rk[x + w] < rk[y + w] : rk[x] < rk[y];
|
||||
});
|
||||
|
||||
rk1 = rk;
|
||||
|
||||
for (int i = 1, p = 0; i <= n; i++) {
|
||||
if (rk1[sa[i]] == rk1[sa[i - 1]] && rk1[sa[i] + w] == rk1[sa[i - 1] + w]) {
|
||||
rk[sa[i]] = p;
|
||||
} else {
|
||||
rk[sa[i]] = ++p;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> s;
|
||||
n = s.size();
|
||||
s = ' ' + s;
|
||||
|
||||
get_sa();
|
||||
|
||||
for (int i = 1; i <= n; i++) cout << sa[i] << ' ';
|
||||
cout << endl;
|
||||
|
||||
return 0;
|
||||
}
|
BIN
S2OJ/305/data/a1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/305/data/a1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/305/data/a1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/305/data/a1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/305/data/a10.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/305/data/a10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/305/data/a10.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/305/data/a10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/305/data/a2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/305/data/a2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/305/data/a2.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/305/data/a2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/305/data/a3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/305/data/a3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/305/data/a3.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/305/data/a3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/305/data/a4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/305/data/a4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/305/data/a4.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/305/data/a4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/305/data/a5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/305/data/a5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/305/data/a5.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/305/data/a5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/305/data/a6.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/305/data/a6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/305/data/a6.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/305/data/a6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/305/data/a7.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/305/data/a7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/305/data/a7.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/305/data/a7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/305/data/a8.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/305/data/a8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/305/data/a8.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/305/data/a8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/305/data/a9.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/305/data/a9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/305/data/a9.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/305/data/a9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/305/data/ex_a1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/305/data/ex_a1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/305/data/ex_a1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/305/data/ex_a1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/305/data/problem.conf
(Stored with Git LFS)
Normal file
BIN
S2OJ/305/data/problem.conf
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user