Advertisement
tumaryui

Untitled

Apr 19th, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define int long long
  3. #define endl "\n"
  4. const int p = 31;
  5.  
  6. using namespace std;
  7. main() {
  8. ios_base::sync_with_stdio(0);
  9. cin.tie(0);
  10. cout.tie(0);
  11. int n;
  12. cin >> n;
  13. vector<string> a(n), b(n);
  14. int tmp = 0;
  15. int l = 0, r = 0;
  16. for(int i = 0; i < n; i++) {
  17. cin >> a[i];
  18. }
  19. for(int i = 0; i < n; i++) {
  20. cin >> b[i];
  21. }
  22. int cnt = 0, pl = 1, pr = 1;;
  23. for(int i = 0; i < n; i++) {
  24. for(int j = 0; j < a[i].size(); j++) {
  25. l += (a[i][j] - 'a' + 1) *pl;
  26. pl *= p;
  27. }
  28. for(int j = 0; j < b[i].size(); j++) {
  29. r += (b[i][j] - 'a' + 1) * pr;
  30. pr *= p;
  31. }
  32. cnt ++;
  33. if(l == r) {
  34. cout << cnt << endl;
  35. cnt = 0;
  36. l = 0;
  37. r = 0;
  38. }
  39. pl = 1;
  40. pr = 1;
  41. }
  42. if(cnt) {
  43. cout << cnt;
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement