题解 | 至
至
https://www.nowcoder.com/practice/36892cfda60144bb9eb8b20f2f61e0b6
#include <bits/stdc++.h>
using namespace std;
int main() {int n, x1, y1, x2, y2;
cin >> n >> x1 >> y1 >> x2 >> y2;
int A1 = (n - y1) + (2 - x1);
int A2 = (n - y2) + (2 - x2);
if (A1 == A2) {
cout << "YES" << endl;
return 0;
}
if ((A1 - A2) % 2 != 0) {
cout << "NO" << endl;
return 0;
}
if (x1 == x2) {
cout << "NO" << endl;
return 0;
}
int x_low, y_low;
if (A1 < A2) {
x_low = x1;
y_low = y1;
} else {
x_low = x2;
y_low = y2;
}
if (x_low == 2) {
if (n - y_low >= 2) cout << "YES" << endl;
else cout << "NO" << endl;
} else {
if (n - y_low >= 3) cout << "YES" << endl;
else cout << "NO" << endl;
}
return 0;
}
