Advertisement
Guest User

Untitled

a guest
Dec 18th, 2018
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. /*
  5.  
  6.  
  7. █▒▒▒▒▒▒▒▒▒
  8. 10%
  9. ███▒▒▒▒▒▒▒
  10. 30%
  11. █████▒▒▒▒▒
  12. 50%
  13. ███████▒▒▒
  14. 70%
  15. ██████████
  16. 100%
  17.  
  18. .
  19. ☁☁☁☁☁☁☁⚡
  20. ☁☁☁☁☁☁⚡☁
  21. ☁☁☁☁☁⚡⚡☁
  22. ☁☁☁☁⚡⚡☁☁
  23. ☁☁☁⚡⚡☁☁☁
  24. ☁☁⚡⚡⚡☁☁☁
  25. ☁⚡⚡⚡☁☁☁☁
  26. ⚡⚡⚡⚡⚡⚡⚡⚡
  27. ⚡⚡⚡⚡⚡⚡⚡⚡
  28. ☁☁☁☁⚡⚡⚡☁
  29. ☁☁☁⚡⚡⚡☁☁
  30. ☁☁☁⚡⚡☁☁☁
  31. ☁☁⚡⚡☁☁☁☁
  32. ☁⚡⚡☁☁☁☁☁
  33. ☁⚡☁☁☁☁☁☁
  34. ⚡☁☁☁☁☁☁☁
  35.  
  36. ▀█▀ █░░ █▀▀ █▀ █░░ ▄▀▄ ▄▀▀ █░░ █▄░█ █▀▀ █░░░█ ▒█▀▀ ▒▄█░
  37. ░█░ █▀▄ █▀▀ █▀ █░▄ █▀█ ░▀▄ █▀▄ █░▀█ █▀▀ █░█░█ ▒▀▀▄ ░▒█░
  38. ░▀░ ▀░▀ ▀▀▀ ▀░ ▀▀▀ ▀░▀ ▀▀░ ▀░▀ ▀░░▀ ▀▀▀ ░▀░▀░ ▒▄▄▀ ▒▄█▄
  39.  
  40. */
  41.  
  42. #define int long long
  43.  
  44. const int N = 5e3 + 3, MOD = 998244353;
  45. pair <string, int> a[N];
  46. char b[N];
  47.  
  48. bool cmp(pair <string, int> a, pair <string , int> b) {
  49. return a.first.size() < b.first.size();
  50. }
  51.  
  52. main()
  53. {
  54. ios_base::sync_with_stdio(0);
  55. cin.tie(0);
  56. int n;
  57. cin >> n;
  58. for (int i = 0; i < n * 2 - 2; i++) {
  59. cin >> a[i].first;
  60. a[i].second = i;
  61. }
  62. sort(a, a + 2 * n - 2, cmp);
  63. string kek = a[0].first, kek1 = a[1].first;
  64. int indx = -1, indx1 = -1;
  65. b[a[0].second] = 'P'; b[a[1].second] = 'S';
  66. for (int i = 2; i < n * 2 - 2; i+= 2) {
  67. string h = "", h1 = "", mem = a[i].first, mem1 = a[i + 1].first;
  68. for (int j = 0; j < kek.size(); j++) h+= mem[j], h1+= mem1[j];
  69. if (h == kek) {
  70. kek = mem;
  71. kek1 = mem1;
  72. b[a[i].second] = 'P';
  73. b[a[i + 1].second] = 'S';
  74. continue;
  75. }
  76. if (h1 == kek) {
  77. kek = mem1;
  78. kek1 = mem;
  79. b[a[i].second] = 'S';
  80. b[a[i + 1].second] = 'P';
  81. continue;
  82. }
  83. swap(b[a[0].second], b[a[1].second]);
  84. swap(kek, kek1);
  85. memas++;
  86. indx = i;
  87. indx1 = i + 1;
  88. if (h == kek) {
  89. kek = mem;
  90. kek1 = mem1;
  91. b[a[i].second] = 'P';
  92. b[a[i + 1].second] = 'S';
  93. continue;
  94. }
  95. if (h1 == kek) {
  96. kek = mem1;
  97. kek1 = mem;
  98. b[a[i].second] = 'S';
  99. b[a[i + 1].second] = 'P';
  100. continue;
  101. }
  102. }
  103. for (int i = 2; i < indx; i++) if (b[a[i].second] == 'P') b[a[i].second] = 'S';
  104. else b[a[i].second] = 'P';
  105. for (int i = 0; i < n * 2 - 2; i++) {
  106. cout << b[i];
  107. }
  108.  
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement