Advertisement
CyberN00b

Untitled

Sep 7th, 2022
871
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define LINT long long int
  3. #define ULINT unsigned long long int
  4. #define INF 99999999999
  5.  
  6. using namespace std;
  7.  
  8. template<typename tmp>
  9. void input(vector<tmp>& vc) {
  10.     for (tmp& x : vc)
  11.         cin >> x;
  12. }
  13. template<typename tmp>
  14. void output(vector<tmp>& vc, string endll = " ", string endd = "\n") {
  15.     for (tmp& x : vc)
  16.         cout << x << endll;
  17.     cout << endd;
  18. }
  19.  
  20. int main(){
  21.     string s1, s2;
  22.     cin >> s1 >> s2;
  23.     vector<int> vc(s1.size(), 0);
  24.     vector<int> ans (26, 0);
  25.     for (int i = 0; i < s1.size(); ++i) {
  26.         if (s1[i] == s2[i]) {
  27.             vc[i] = 2;
  28.         } else {
  29.             ans[int(s1[i]) - int('A')] += 1;
  30.             }
  31.     }
  32.     for (int i = 0; i < vc.size(); ++i) {
  33.         if (vc[i] == 2) {
  34.             cout << 'P';
  35.         } else
  36.             if (ans[int(s2[i]) - int('A')]) {
  37.                 ans[int(s2[i]) - int('A')]--;
  38.                 cout << 'S';
  39.             } else
  40.                 cout << 'I';
  41.     }
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement