标签:
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 234 Accepted Submission(s): 110
题意:给你象棋中所有车的位置,每次询问矩形给你左上角和右上角的点,问这个矩形中的点是否可以被车吃完。
#include<iostream> #include<cstdio> #include<cstring> using namespace std; #define maxn 110008 int x[maxn], y[maxn]; int main() { int t, n, m, k, q, a, b, x1, x2, y1, y2; scanf("%d", &t); while(t--) { scanf("%d%d%d%d", &n, &m, &k, &q); memset(x, 0, sizeof(x)); memset(y, 0, sizeof(y)); for(int i = 0; i < k; i++) { scanf("%d%d", &a, &b); x[a] = 1; y[b] = 1; } for(int i = 2; i <= n; i++) x[i] += x[i-1]; for(int i = 2; i <= m; i++) y[i] += y[i-1]; for(int w = 0; w < q; w++) { int i, j; scanf("%d%d%d%d", &x1, &y1, &x2, &y2); if(x[x2]-x[x1-1] == x2-x1+1 || y[y2]-y[y1-1] == y2-y1+1) // 每次查询看是否矩形所在的所有行或所有列全部被车吃掉 printf("Yes\n"); else printf("No\n"); } } return 0; }
标签:
原文地址:http://www.cnblogs.com/Tinamei/p/4841862.html