当前位置: 代码迷 >> 综合 >> poj 3881 区间交判断
  详细解决方案

poj 3881 区间交判断

热度:61   发布时间:2024-01-19 05:48:13.0

水题,直接贴代码。

//poj 3881
//sep9
#include <iostream>
using namespace std;
const int maxN=10024;
int n,m;
int a[maxN],b[maxN];
bool judge(int x,int y,int i)
{if(b[i]<=x||y<=a[i])return false;	return true;
}int main()
{while(scanf("%d%d",&n,&m)==2&&(m+n)){for(int i=0;i<n;++i){scanf("%*d%*d%d%d",&a[i],&b[i]);			b[i]+=a[i];}while(m--){int x,y,cnt=0;	scanf("%d%d",&x,&y);y+=x;for(int i=0;i<n;++i)if(judge(x,y,i))	++cnt;printf("%d\n",cnt);}}return 0;	
}