题解:P13822 「Diligent-OI R2 B」白露为霜
Charged_Charge · · 题解
洛谷 P13822
前言:
比第一题好想、简单多了,我就是先开这题,再做第一题的。
题目大意:
定义一个序列为折线,当且仅当
解题思路:
我的思路是通过奇偶性判断。比如:当前的
AC 代码:
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e6+20;
int t;
int a[N], b[N];
signed main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> t;
while (t--) {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
cin >> b[i];
}
if (n == 1) {
cout << "Yes" << endl;
continue;
}
bool ok = false;
for (int i = 1; i <= n; i++) {
if (a[i] % 2 != b[i] % 2) {
ok = true;
break;
}
}
if (ok) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
}
}
return 0;
}