您的位置:首页 > 其它

HDU 5258(水暴力)

2015-06-12 18:19 239 查看
题意 :中文题 不描述了 暴力四条边。

代码:

#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);
     }    
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: