SuffixArray_test.cpp 666 B

1234567891011121314151617181920212223242526272829
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef vector<int> VI;
  4. typedef vector<VI> VVI;
  5. typedef pair<int, int> PII;
  6. #include "SuffixArray.cpp"
  7. int main() {
  8. // bobocel is the 0'th suffix
  9. // obocel is the 5'th suffix
  10. // bocel is the 1'st suffix
  11. // ocel is the 6'th suffix
  12. // cel is the 2'nd suffix
  13. // el is the 3'rd suffix
  14. // l is the 4'th suffix
  15. SuffixArray suffix("bobocel");
  16. VI v = suffix.GetSuffixArray();
  17. assert(v[0] == 0);
  18. assert(v[1] == 5);
  19. assert(v[2] == 1);
  20. assert(v[3] == 6);
  21. assert(v[4] == 2);
  22. assert(v[5] == 3);
  23. assert(v[6] == 4);
  24. assert(suffix.LongestCommonPrefix(0, 2) == 2);
  25. return 0;
  26. }