fork(1) download
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. string s;
  10. cin >> s;
  11.  
  12. for (size_t q=1, n=0, w=~0U; q<s.length(); ++q)
  13. if (n)
  14. cout << s[q] << ' ' << s[++w %= n] << endl;
  15. else if (equal(s.begin(), s.begin()+q, s.rend()-1-q))
  16. n = q+1 >> 1;
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0s 15240KB
stdin
PassssaPandsometext
stdout
a P
n a
d s
s s
o P
m a
e s
t s
e P
x a
t s