Official
A - Black Square Editorial by en_translator
Cell \((X,Y)\) is painted black if and only if \(P\leq X<P+100\) and \(Q\leq Y<Q+100\).
(Note that \(P\leq X\leq P+100\) (or \(Q\leq Y\leq Q+100\)) is wrong.)
Therefore, we may print Yes if \(P\leq X< P+100\) and \(Q\leq Y<Q+100\), and No otherwise. This can be implementing using an if statement.
Since \(P,Q,X\), and \(Y\) are integers, we can alternatively use \(P\leq X \leq P+99\) and \(Q\leq Y\leq Q+99\).
Sample code in C++:
#include <bits/stdc++.h>
using namespace std;
int main() {
int p, q, x, y;
cin >> p >> q;
cin >> x >> y;
if( (p<=x) && (x<p+100) && (q<=y) && (y<q+100) )cout << "Yes" << endl;
else cout << "No" << endl;
return 0;
}
Sample code in Python:
p,q=map(int, input().split())
x,y=map(int, input().split())
if p<=x and x<p+100 and q<=y and y<q+100:
print("Yes")
else:
print("No")
posted:
last update: