Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define int long long
- #define endl "\n"
- const int p = 31;
- using namespace std;
- main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- int n;
- cin >> n;
- vector<string> a(n), b(n);
- int tmp = 0;
- int l = 0, r = 0;
- for(int i = 0; i < n; i++) {
- cin >> a[i];
- }
- for(int i = 0; i < n; i++) {
- cin >> b[i];
- }
- int cnt = 0, pl = 1, pr = 1;;
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < a[i].size(); j++) {
- l += (a[i][j] - 'a' + 1) *pl;
- pl *= p;
- }
- for(int j = 0; j < b[i].size(); j++) {
- r += (b[i][j] - 'a' + 1) * pr;
- pr *= p;
- }
- cnt ++;
- if(l == r) {
- cout << cnt << endl;
- cnt = 0;
- l = 0;
- r = 0;
- }
- pl = 1;
- pr = 1;
- }
- if(cnt) {
- cout << cnt;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement