Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <tuple>
- #include <set>
- #include <map>
- #include <cmath>
- #include <string>
- #include <algorithm>
- #define int long long
- #define all(x) (x).begin(), (x).end()
- #define allr(x) (x).rbegin(), (x).rend()
- using namespace std;
- const int MOD = 1e9 + 7;
- const int INF = 1e9;
- int gcd(int a, int b)
- {
- return (a == 0 ? b : gcd(b % a, a));
- }
- signed main()
- {
- int q;
- cin >> q;
- while(q--)
- {
- int n;
- cin >> n;
- vector <int> a(n), b(n);
- for (int i = 0; i < n; ++i)
- cin >> a[i];
- for (int i = 0; i < n; ++i)
- cin >> b[i];
- if (a[0] != b[0])
- cout << "NO\n";
- else
- {
- bool gotUp = 0, gotDown = 0, got1 = 0, gotm1 = 0, imp = 0;
- for (int i = 0; i < n; ++i)
- {
- if (a[i] < b[i])
- gotUp = 1;
- if (a[i] > b[i])
- gotDown = 1;
- if ((!got1 && gotUp) || (!gotm1 && gotDown))
- {
- imp = 1;
- break;
- }
- if (a[i] == 1)
- got1 = 1;
- if (a[i] == -1)
- gotm1 = 1;
- }
- if (imp)
- cout << "NO\n";
- else
- cout << "YES\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement