Advertisement
Guest User

Untitled

a guest
May 29th, 2014
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cassert>
  4. #include <cmath>
  5. #include <cstring>
  6. #include <vector>
  7. #include <algorithm>
  8. #include <stack>
  9. using namespace std;
  10.  
  11. vector <char> p;
  12.  
  13. bool check1[100005], check2[100005];
  14.  
  15.  
  16. int main()
  17. {
  18. string s1,s2;
  19.  
  20. cin >> s1 >> s2;
  21.  
  22. long long n = s1.length();
  23.  
  24. for (int i = 0; i < n; i++)
  25. for (int j = 0; j < n; j++)
  26. {
  27. if (s1[i] == s2[j] && check1[i] == false && check2[j] == false)
  28. {
  29. p.push_back(s1[i]);
  30. check1[i] = true;
  31. check2[j] = true;
  32. }
  33. }
  34.  
  35. long long maxs,x = 0, l = 0;
  36.  
  37. n = p.size();
  38.  
  39. while (n - l > 0)
  40. {
  41. maxs = 0;
  42. for (int j = x; j < n; j++)
  43. {
  44. if (int(p[j]) > maxs)
  45. {
  46. maxs = int(p[j]);
  47. l = j+1;
  48. }
  49. }
  50. cout << char(maxs);
  51. //cout << l;
  52. x = l;
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement