Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- n = n - 1;
- int m = n + n;
- string a, b;
- int count = 0;
- char c = '!';
- vector<string> s(m);
- for(int i = 0; i < m; i++) {
- cin >> s[i];
- if(s[i].size() == n) {
- if(a == "")
- a = s[i];
- else
- b = s[i];
- }
- if(c == '!')
- c = s[i][0];
- if(s[i][0] == c)
- count++;
- }
- if(count < (m / 2) && a[0] == c) {
- swap(a, b);
- }
- vector<bool> bo(m);
- for(int i = 0; i < m; i++) {
- if(s[i].size() != n) {
- if (a.rfind(s[i], 0) == 0 && bo[s[i].size() - 1] == false) {
- cout << "P";
- bo[s[i].size() - 1] = true;
- }
- else
- cout << "S";
- }
- else {
- if(s[i] == a && bo[s[i].size() - 1] == false) {
- cout << "P";
- bo[s[i].size() - 1] = true;
- }
- else
- cout << "S";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement