Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define int int64_t
- #define double long double
- #define F first
- #define S second
- #define pb push_back
- #define pf push_front
- #define ppb pop_back();
- #define ppf pop_front();
- #define FOR(i, n) for (i; i < n; i++)
- #define For(n) for (int i = 1; i < n; i++)
- #define optimization ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
- #define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
- using namespace std;
- typedef pair <int, int> pii;
- typedef deque <int> di;
- typedef deque <pii> dii;
- bool solve()
- {
- int n;
- cin >> n;
- int a [n], b [n];
- for (auto &i: a)
- cin >> i;
- for (auto &i: b)
- cin >> i;
- if(a [0] != b [0])
- return 0;
- bool have_minus = 0, have_plus = 0;
- if (a [0] < 0)
- have_minus = 1;
- if (a [0] > 0)
- have_plus = 1;
- For(n)
- {
- if ((a [i] < b [i] && have_plus == 0) || (a [i] > b [i] && have_minus == 0))
- return 0;
- if (a [i] == -1)
- have_minus = 1;
- if (a [i] == 1)
- have_plus = 1;
- }
- return 1;
- }
- int32_t main()
- {
- //file
- optimization
- int t;
- cin >> t;
- while (t--)
- {
- if (solve())
- cout << "YES\n";
- else
- cout << "NO\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment