cf1058b 点是否在一个矩形里
判断点是否在一个矩形里 用点和4条直线的关系
http://codeforces.com/contest/1058/problem/B
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define all(v) v.begin(),v.end() #define fi first #define se second const int N =1e5+5; const ll mod = 1e9+7; const int INF = 1E8+4; int n,d; //http://codeforces.com/contest/1058/problem/B //判断点是否在一个矩形里 用点和4条直线的关系 bool c(int x,int y){ if(x-y<-d)return false; if(x-y>d)return false; if(x+y<d)return false; if(x+y>2*n-d)return false; return true; } int main(){ cin>>n>>d; int m; cin>>m; while(m--){ int a,v; cin>>a>>v; if(c(a,v))cout<<"YES"<<endl; else cout<<"NO"<<endl; } return 0; }