Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <cassert>
- #include <cmath>
- #include <cstring>
- #include <vector>
- #include <algorithm>
- #include <stack>
- using namespace std;
- vector <char> p;
- bool check1[100005], check2[100005];
- int main()
- {
- string s1,s2;
- cin >> s1 >> s2;
- long long n = s1.length();
- for (int i = 0; i < n; i++)
- for (int j = 0; j < n; j++)
- {
- if (s1[i] == s2[j] && check1[i] == false && check2[j] == false)
- {
- p.push_back(s1[i]);
- check1[i] = true;
- check2[j] = true;
- }
- }
- long long maxs,x = 0, l = 0;
- n = p.size();
- while (n - l > 0)
- {
- maxs = 0;
- for (int j = x; j < n; j++)
- {
- if (int(p[j]) > maxs)
- {
- maxs = int(p[j]);
- l = j+1;
- }
- }
- cout << char(maxs);
- //cout << l;
- x = l;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement