Advertisement
ibragimova_mariam

Untitled

Dec 18th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. int main()
  6. {
  7. int n;
  8. cin >> n;
  9. n = n - 1;
  10. int m = n + n;
  11. string a, b;
  12.  
  13. int count = 0;
  14. char c = '!';
  15. vector<string> s(m);
  16. for(int i = 0; i < m; i++) {
  17. cin >> s[i];
  18. if(s[i].size() == n) {
  19. if(a == "")
  20. a = s[i];
  21. else
  22. b = s[i];
  23. }
  24. if(c == '!')
  25. c = s[i][0];
  26. if(s[i][0] == c)
  27. count++;
  28. }
  29.  
  30.  
  31. if(count < (m / 2) && a[0] == c) {
  32. swap(a, b);
  33. }
  34.  
  35. vector<bool> bo(m);
  36.  
  37. for(int i = 0; i < m; i++) {
  38. if(s[i].size() != n) {
  39. if (a.rfind(s[i], 0) == 0 && bo[s[i].size() - 1] == false) {
  40. cout << "P";
  41. bo[s[i].size() - 1] = true;
  42. }
  43. else
  44. cout << "S";
  45. }
  46. else {
  47. if(s[i] == a && bo[s[i].size() - 1] == false) {
  48. cout << "P";
  49. bo[s[i].size() - 1] = true;
  50. }
  51. else
  52. cout << "S";
  53. }
  54.  
  55. }
  56.  
  57.  
  58. return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement