比赛 |
20120722 |
评测结果 |
AAAAAAAATTTTTTTTTTTT |
题目名称 |
切割矩形 |
最终得分 |
40 |
用户昵称 |
Truth.Cirno |
运行时间 |
12.003 s |
代码语言 |
C++ |
内存使用 |
0.75 MiB |
提交时间 |
2012-07-22 12:42:40 |
显示代码纯文本
#include <cstdio>
using namespace std;
int x1[30000],y1[30000],x2[30000],y2[30000];
int main(void)
{
freopen("cutting.in","r",stdin);
freopen("cutting.out","w",stdout);
int times,i,j,T,n,q,c,a1,b1,a2,b2;
scanf("%d",&T);
for (times=0;times<T;times++)
{
c=0;
scanf("%d",&n);
for (i=0;i<n;i++)
scanf("%d%d%d%d",&x1[i],&y1[i],&x2[i],&y2[i]);
scanf("%d",&q);
for (i=0;i<q;i++)
{
scanf("%d%d%d%d",&a1,&b1,&a2,&b2);
if (a1==a2)
{
for (j=0;j<n;j++)
{
if (x1[j]<=a1&&a1<=x2[j])
{
if ((b1<=y1[j]&&y2[j]<=b2)||(b1>=y1[j]&&b1<=y2[j])||(b2>=y1[j]&&b2<=y2[j]))
c++;
}
}
}
else
{
for (j=0;j<n;j++)
{
if (y1[j]<=b1&&b1<=y2[j])
{
if ((a1<=x1[j]&&x2[j]<=a2)||(a1>=x1[j]&&a1<=x2[j])||(a2>=x1[j]&&a2<=x2[j]))
c++;
}
}
}
}
printf("%d\n",c);
}
return(0);
}