fork(1) download
  1. #include <cstdio>
  2. #include <algorithm>
  3. #include <cstring>
  4. using namespace std;
  5.  
  6. #define MAXN 65536
  7. #define MAXLG 17
  8.  
  9. char A[MAXN];
  10.  
  11. struct entry
  12. {
  13. int nr[2];
  14. int p;
  15. } L[MAXN];
  16.  
  17. int P[MAXLG][MAXN];
  18. int N,i;
  19. int stp, cnt;
  20.  
  21. int cmp(struct entry a, struct entry b)
  22. {
  23. return a.nr[0]==b.nr[0] ?(a.nr[1]<b.nr[1] ?1: 0): (a.nr[0]<b.nr[0] ?1: 0);
  24. }
  25.  
  26. int main()
  27. {
  28. gets(A);
  29. for(N=strlen(A), i = 0; i < N; i++)
  30. P[0][i] = A[i] - 'a';
  31.  
  32. for(stp=1, cnt = 1; cnt < N; stp++, cnt *= 2)
  33. {
  34. for(i=0; i < N; i++)
  35. {
  36. L[i].nr[0]=P[stp- 1][i];
  37. L[i].nr[1]=i +cnt <N? P[stp -1][i+ cnt]:-1;
  38. L[i].p= i;
  39. }
  40. sort(L, L+N, cmp);
  41. for(i=0; i < N; i++)
  42. P[stp][L[i].p] =i> 0 && L[i].nr[0]==L[i-1].nr[0] && L[i].nr[1] == L[i- 1].nr[1] ? P[stp][L[i-1].p] : i;
  43. }
  44. return 0;
  45. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:28:11: error: 'gets' was not declared in this scope
     gets(A);
           ^
stdout
Standard output is empty