HDU 5258(水暴力)

题意 :中文题 不描述了    暴力四条边。 

代码:

#include<stdio.h>
struct Node
{
   int x1, y1, x2, y2;       
}cunh[26], cuns[25];
int Max(int a, int b)
{
   if(a > b)      return a;
   return b;
} 
int Min(int a, int b)
{
   if(a < b)      return a;
   return b;    
}
int ok(int i, int j)
{
   if(cuns[i].x1 > cunh[j].x2 || cuns[i].x2 < cunh[j].x1)return 0;
   if(cuns[i].y1 > cunh[j].y2 || cuns[i].y2 < cunh[j].y1)return 0;
   return 1;
}
int main()
{
     int T, n, x1, x2, y1, y2, t, coun = 1;
     scanf("%d", &T);
     while(T--)
     {
          scanf("%d", &n);
          int cnt, tot;
          cnt = tot = 0;
          for(int i = 1; i <= n; i++)
          {
              scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
              if(x1 == x2)
              {
               if(y1 > y2)  t = y1, y1 = y2, y2 = t;
               cunh[tot].x1 = x1, cunh[tot].x2 = x2, cunh[tot].y1 = y1, cunh[tot++].y2 = y2;
              }
              if(y1 == y2)
              {
               if(x1 > x2)  t = x1, x1 = x2, x2 = t;
               cuns[cnt].x1 = x1, cuns[cnt].x2 = x2, cuns[cnt].y1 = y1, cuns[cnt++].y2 = y2;
              } 
          }      
          __int64 num = 0;
          for(int i = 0; i < cnt; i++)
          for(int j = i+1; j < cnt; j++)
          for(int k = 0; k < tot; k ++)
          for(int p = k+1; p < tot; p++)
          {
               if(ok(i, k) && ok(i, p) && ok(j, k) && ok(j, p)) 
               num ++;
          }   
          printf("Case #%d:\n", coun ++);
          printf("%I64d\n", num);
     }    
} 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值