Mysterious Antiques in Sackler Museum(判断长方形)
题意:大概意思就是判断四个矩形能不能从中选取三个矩形组成一个大的矩形。
题解:
- 从四个矩形中任选三个,这样有四种选法。
- 三个矩形能凑成一个矩形首先是两个矩形有一条边相等,第三个矩形要么有边跟他们相等的边相等,要么有边跟他们不相等的边的和相等(有点绕)。
想明白这两点之后直接暴力就可以了,当时训练赛的时候因为读错题然后一直WA烦躁一直没法静下心来想,修养不够,修养不够。
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <queue>
using namespace std;
struct node
{
int a,b;
}s[5],tmp;
node judge(node a,node b)/*这里返回结构体,这样可以减少好多代码,相当于两个矩形构成了一个新的矩形*/
{
if(a.a==b.a)
return (node){a.a,a.b+b.b};
if(a.b==b.a)
return (node){a.b,a.a+b.b};
if(a.a==b.b)
return (node){a.a,a.b+b.a};
if(a.b==b.b)
return (node){a.b,a.a+b.a};
return (node){0,0};
}
int pd(node a,node b,node c)
{
tmp = judge(a,b);
tmp = judge(tmp,c);
if(tmp.a>0)
return 1;
tmp = judge(a,c);
tmp = judge(tmp,b);
if(tmp.a>0)
return 1;
tmp = judge(b,c);
tmp = judge(tmp,a);
if(tmp.a>0)
return 1;
return 0;
}
int main()
{
int t,i;
scanf("%d",&t);
while(t--)
{
for(i=0;i<4;i++)
scanf("%d%d",&s[i].a,&s[i].b);
if(pd(s[0],s[1],s[2]))
{
printf("Yes\n");
continue;
}
if(pd(s[0],s[1],s[3]))
{
printf("Yes\n");
continue;
}
if(pd(s[0],s[2],s[3]))
{
printf("Yes\n");
continue;
}
if(pd(s[1],s[2],s[3]))
{
printf("Yes\n");
continue;
}
printf("No\n");
}
return 0;
}
Mysterious Antiques in Sackler Museum(判断长方形)的更多相关文章
- UVALive 7267 Mysterious Antiques in Sackler Museum (判断长方形)
Sackler Museum of Art and Archaeology at Peking University is located on a beautiful site near the W ...
- 【hihocoder1255 Mysterious Antiques in Sackler Museum】构造 枚举
2015北京区域赛现场赛第2题. 题面:http://media.hihocoder.com/contests/icpcbeijing2015/problems.pdf OJ链接:http://hih ...
- hiho1255 Mysterious Antiques in Sackler Museum
题目链接:http://media.hihocoder.com/contests/icpcbeijing2015/problems.pdf 题目大意:给你四个矩形,判断是否能取其中任意三个组成一个大矩 ...
- UVaLive 7267 Mysterious Antiques in Sackler Museum (if-else,枚举)
题意:给定四个矩形,要求从中选出三个,能不能拼成一个矩形. 析:说到这个题,我还坑了队友一次,读题读错了,我直接看的样例,以为是四个能不能组成,然后我们三个就拼命想有什么简便方法,后来没办法了,直接暴 ...
- 2015北京区域赛 Mysterious Antiques in Sackler Museum 几何基础+思维
题意是,选出三个,看看是否可以凑成一个新的矩形. #include<bits/stdc++.h> using namespace std; struct node { ]; }a[]; b ...
- CodeForces 596A
Description After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the ...
- 院校-美国:哈佛大学(Harvard University)
ylbtech-院校-美国:哈佛大学(Harvard University) 哈佛大学(Harvard University),简称“哈佛”,坐落于美国马萨诸塞州波士顿都市区剑桥市,是一所享誉世界的私 ...
- matlab-霍夫变换详解(判断正方形长方形)
霍夫变换 霍夫变换是1972年提出来的,最开始就是用来在图像中过检测直线,后来扩展能检测圆.曲线等. 直线的霍夫变换就是 把xy空间的直线 换成成 另一空间的点.就是直线和点的互换. 我们在初中数学中 ...
- POJ2653判断直线是否相交
bool judge(node p1,node p2,node p3,node p4){ if(min(p1.x,p2.x)>max(p3.x,p4.x)||min(p1.y,p2.y)& ...
随机推荐
- sql 书写顺序
SELECT select_list [ INTO new_table ] FROM table_source [ WHERE search_condition ] [ GROUP BY group_ ...
- 在rabbitmq操作页面上添加队列、交换器及绑定示图
1.添加队列 2.添加交换器 3.绑定
- Spring MVC 搭建web项目示例
环境为Eclipse 1:新建Dynamic web project : springMvcDemo 2:下载spring的jar包,把jar包复制到WEB-INF/lib目录下 3.添加配置文件w ...
- [jnhs]未完待续HttpServletRequest示例
uri: /kaihu/showip.html method: GET QueryString: null Parameters: Headers: Name: host Value: localho ...
- Python学习(一) 安装,环境搭建,IDE
第一篇废话太多了,我的博客最主要的是给自己看的,大家觉得还凑合也可以看看,能说自己想法的就更好了,因为一个人的思想是有局限性的.集思广益,自己的认知才不会被禁锢. 注:其他的系统没装,在Windows ...
- day38 06-MyEclipse配置Schema约束
- 强强联合 阿里云 RDS for SQL Server 与 金蝶 K/3 WISE 产品实现兼容适配
强强联合 阿里云 RDS for SQL Server 与 金蝶 K/3 WISE 产品实现兼容适配,原K/3 WISE用户通过简单配置就可以无缝搭配RDS SQL Server使用,不需再费时费力自 ...
- 【BZOJ2809】【APIO2012】dispatching
左偏树. 每个子节点维护大根堆,遍历一个儿子就往自己合并,合并发现钱不够了就删除队顶. //Achen #include<algorithm> #include<iostream&g ...
- 微信小程序--flex常用的属性
Flex布局 display:flex 指定当前盒子为伸缩盒 flex-direction:column 把盒子内容垂直从上往下排列 row 把盒子内容垂直从左往右排列 flex-wrap: wrap ...
- Codeforces 3D
题目链接 D. Least Cost Bracket Sequence time limit per test 1 second memory limit per test 64 megabytes ...