题目链接

题意:大概意思就是判断四个矩形能不能从中选取三个矩形组成一个大的矩形。

题解:

  • 从四个矩形中任选三个,这样有四种选法。
  • 三个矩形能凑成一个矩形首先是两个矩形有一条边相等,第三个矩形要么有边跟他们相等的边相等,要么有边跟他们不相等的边的和相等(有点绕)。

想明白这两点之后直接暴力就可以了,当时训练赛的时候因为读错题然后一直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(判断长方形)的更多相关文章

  1. 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 ...

  2. 【hihocoder1255 Mysterious Antiques in Sackler Museum】构造 枚举

    2015北京区域赛现场赛第2题. 题面:http://media.hihocoder.com/contests/icpcbeijing2015/problems.pdf OJ链接:http://hih ...

  3. hiho1255 Mysterious Antiques in Sackler Museum

    题目链接:http://media.hihocoder.com/contests/icpcbeijing2015/problems.pdf 题目大意:给你四个矩形,判断是否能取其中任意三个组成一个大矩 ...

  4. UVaLive 7267 Mysterious Antiques in Sackler Museum (if-else,枚举)

    题意:给定四个矩形,要求从中选出三个,能不能拼成一个矩形. 析:说到这个题,我还坑了队友一次,读题读错了,我直接看的样例,以为是四个能不能组成,然后我们三个就拼命想有什么简便方法,后来没办法了,直接暴 ...

  5. 2015北京区域赛 Mysterious Antiques in Sackler Museum 几何基础+思维

    题意是,选出三个,看看是否可以凑成一个新的矩形. #include<bits/stdc++.h> using namespace std; struct node { ]; }a[]; b ...

  6. CodeForces 596A

    Description After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the ...

  7. 院校-美国:哈佛大学(Harvard University)

    ylbtech-院校-美国:哈佛大学(Harvard University) 哈佛大学(Harvard University),简称“哈佛”,坐落于美国马萨诸塞州波士顿都市区剑桥市,是一所享誉世界的私 ...

  8. matlab-霍夫变换详解(判断正方形长方形)

    霍夫变换 霍夫变换是1972年提出来的,最开始就是用来在图像中过检测直线,后来扩展能检测圆.曲线等. 直线的霍夫变换就是 把xy空间的直线 换成成 另一空间的点.就是直线和点的互换. 我们在初中数学中 ...

  9. 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)& ...

随机推荐

  1. jquery版本冲突问题

    开发过程中,我们常常会遇到这种问题: 我们需要做一个新的功能,需要插入一个新的插件,使用新版的jquery,但原版的jquery已经被很多函数使用,不能直接修改.这时候我们可以现将$转移给$170($ ...

  2. vim Tab的设置问题

    VIM 中处理 TAB 异常的方便. 键盘上的 TAB 键,与文件中的 TAB 符号一定要区分开,这是两个概念. 显示当前文件中的 Tab /\t 实际上,就是查询 \t 符号. shiftwidth ...

  3. LR自带网站飞机订票系统 启动

    LR自带的网站:飞机订票系统 可是如何启动自带的网站呢?? 一.启动服务:开始-所有程序--HP Software-HP LoadRunner-Samples-Web-Start Web Server ...

  4. @import vs #import - iOS 7

    It's a new feature called Modules or "semantic import". There's more info in the WWDC 2013 ...

  5. 群晖安装transmission

    首先 需要添加第三方的套件下载地址 http://packages.synocommunity.com/ 然后找到tr 根据需要设置文件夹路径 因为我需要跑rss,所以用到了flexget,先放这里 ...

  6. hibernate hql语句 group by having 的坑

    我期望获得这个列表 然而,使用hql只能获得第一条数据,后来我琢磨了一下,和group by有关系 应该改成 成功查询到

  7. Oracle 优化效率

    一.链接: ORACLE多表查询优化 oracle的 分表 详解 -----表分区 Oracle数据库查询优化方案(处理上百万级记录如何提高处理查询速度) 数据库SQL优化大总结之 百万级数据库优化方 ...

  8. Ubuntu 安装 RabbitMQ 和PHP扩展 - CSDN博客

    1.ubuntu16.04中安装RabbitMQ 1).首先必须要有Erlang环境支持 安装之前要装一些必要的库: sudo apt-get install build-essential  sud ...

  9. 让Drewtech的J2534 ToolBox 软件支持任何J2534的设备

    更改windows注册表中的FunctionLibrary和ConfigApplication,将DLL和exe路径替换原来的,其他不要动. 或者 create second key in regis ...

  10. BZOJ 3296: [USACO2011 Open] Learning Languages

    Time Limit: 5 Sec Memory Limit: 128 MB Submit: 387 Solved: 206 [Submit][Status][Discuss] Description ...