ProgMe

Untitled

Apr 8th, 2020
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define int int64_t
  3. #define double long double
  4. #define F first
  5. #define S second
  6. #define pb push_back
  7. #define pf push_front
  8. #define ppb pop_back();
  9. #define ppf pop_front();
  10. #define FOR(i, n) for (i; i < n; i++)
  11. #define For(n) for (int i = 1; i < n; i++)
  12. #define optimization ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  13. #define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
  14.  
  15. using namespace std;
  16. typedef pair <int, int> pii;
  17. typedef deque <int> di;
  18. typedef deque <pii> dii;
  19.  
  20. bool solve()
  21. {
  22. int n;
  23. cin >> n;
  24. int a [n], b [n];
  25. for (auto &i: a)
  26. cin >> i;
  27. for (auto &i: b)
  28. cin >> i;
  29. if(a [0] != b [0])
  30. return 0;
  31. bool have_minus = 0, have_plus = 0;
  32. if (a [0] < 0)
  33. have_minus = 1;
  34. if (a [0] > 0)
  35. have_plus = 1;
  36. For(n)
  37. {
  38. if ((a [i] < b [i] && have_plus == 0) || (a [i] > b [i] && have_minus == 0))
  39. return 0;
  40. if (a [i] == -1)
  41. have_minus = 1;
  42. if (a [i] == 1)
  43. have_plus = 1;
  44. }
  45. return 1;
  46. }
  47.  
  48. int32_t main()
  49. {
  50. //file
  51. optimization
  52. int t;
  53. cin >> t;
  54. while (t--)
  55. {
  56. if (solve())
  57. cout << "YES\n";
  58. else
  59. cout << "NO\n";
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment