Advertisement
Guest User

Untitled

a guest
Feb 18th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define FOR(i, a, b) for(int i = (a); i < (b); ++i)
  5. #define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
  6. #define FILL(A,value) memset(A,value,sizeof(A))
  7.  
  8. #define ALL(V) V.begin(), V.end()
  9. #define SZ(V) (int)V.size()
  10. #define PB push_back
  11. #define MP make_pair
  12. const double PI = acos(-1.0);
  13.  
  14. typedef long long Int;
  15. typedef long long LL;
  16. typedef unsigned long long UINT;
  17. typedef vector <int> VI;
  18. typedef pair <int, int> PII;
  19. typedef pair <double, double> PDD;
  20.  
  21. const int INF = 1000 * 1000 * 1000 + 7;
  22. const LL LINF = INF * (LL)INF;
  23. const int MAX = 407;
  24.  
  25. int c[256];
  26.  
  27. int main()
  28. {
  29. string a, b;
  30. cin >> a >> b;
  31.  
  32. int pos = 0, res = 0;
  33. FOR (i,0,SZ(b))
  34. {
  35. while (pos < SZ(a) && a[pos] != b[i])
  36. {
  37. ++ c[a[pos]];
  38. ++ pos;
  39. }
  40.  
  41. if (pos == SZ(a))
  42. {
  43. cout << -1 << endl;
  44. return 0;
  45. }
  46. ++ pos;
  47. }
  48.  
  49. while (pos < SZ(a))
  50. {
  51. ++ c[a[pos]];
  52. ++ pos;
  53. }
  54.  
  55. FOR (i,0,256)
  56. res = max(res, c[i]);
  57.  
  58. cout << (res+1)/2 << endl;
  59.  
  60.  
  61. return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement