-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsuffix_array.cpp
More file actions
35 lines (32 loc) · 808 Bytes
/
suffix_array.cpp
File metadata and controls
35 lines (32 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
using std::cin;
using std::cout;
using std::endl;
using std::make_pair;
using std::pair;
using std::string;
using std::vector;
// Build suffix array of the string text and
// return a vector result of the same length as the text
// such that the value result[i] is the index (0-based)
// in text where the i-th lexicographically smallest
// suffix of text starts.
vector<int> BuildSuffixArray(const string& text) {
vector<int> result;
// Implement this function yourself
return result;
}
int main() {
string text;
cin >> text;
vector<int> suffix_array = BuildSuffixArray(text);
for (int i = 0; i < suffix_array.size(); ++i) {
cout << suffix_array[i] << ' ';
}
cout << endl;
return 0;
}