Codeforces Round #512 (Div. 2, based on Technocup 2019 Elimination Round 1) B. Vasya and Cornfield
阿新 • • 發佈:2018-12-23
題解
題目大意 n和d 還有m個點的x y座標 問座標是否在(0, d) (d, 0) (n-d, n) (n, n-d)四個點圍城的矩形內
判斷矩形不好判斷 可以判斷是否在四個角的三角形內 不包括邊上
AC程式碼
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
int main()
{
#ifdef LOCAL
freopen("C:/input.txt", "r", stdin);
#endif
int n, m, d;
cin >> n >> d >> m;
for (int i = 0; i < m; i++)
{
int x, y, xx, yy;
cin >> x >> y;
int flag = 1;
xx = x, yy = y;
if (xx + yy < d)
flag = 0;
xx = n - x, yy = y;
if (xx + yy < n - d)
flag = 0;
xx = n - x, yy = n - y;
if (xx + yy < d)
flag = 0;
xx = x, yy = n - y;
if (xx + yy < n - d)
flag = 0;
if (flag)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}