题目链接

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

题解:

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

想明白这两点之后直接暴力就可以了,当时训练赛的时候因为读错题然后一直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. Java程序员面试题收集(2)

    1 String = 与 new 的不同 使用“=”赋值不一定每次都创建一个新的字符串,而是从“字符串实例池”中查找字符串.使用“new”进行赋值,则每次都创建一个新的字符串.  2 String与S ...

  2. c++ 链接mysql:error LNK2019: 无法解析的外部符号

    使用VS2012编译项目报错如下: error LNK2019: 无法解析的外部符号 _mysql_real_connect@32,该符号在函数 _main 中被引用 error LNK2019: 无 ...

  3. hbase设计方案1

    好的方案应该挺多的,比如:可以将[日.周.月]以3,2,1来表示(拼接到ROW_KEY中){离线跑job时候,可以分为月job(每月末run一下,周job(每周末run一下),日job(每天run一下 ...

  4. org.apache.ant实现压缩和解压

    <dependency> <groupId>org.apache.ant</groupId> <artifactId>ant</artifactI ...

  5. MySQL与Oracle差异函数对比

    ORACLE:select round(1.23456,4) value from dual MYSQL:select round(1.23456,4) value 2 abs(-1) abs(-1) ...

  6. Javascript-循环输出菱形,并可菱形自定义大小

    var Cen = 6;//定义菱形中部为第几行(起始值为0) //for循环输出菱形 document.write("<button onclick='xh()'>点我for循 ...

  7. 了解真实的『REM』多终端屏幕适配

    作者:hbxeagle 链接:github.com/hbxeagle/rem/blob/master/README.md rem 作为一个低调的长度单位,由于手机端网页的兴起,在屏幕适配中得到重用.使 ...

  8. 优雅的css写法

    一.利用好代码折叠 css也可以进行优雅的代码折叠而且会比html更好看 折叠后的效果: 这样就可以很舒服的把它折叠起来. 二.向Twitter Bootstrap学习 1. 学习的第一点就是用cla ...

  9. springmvc框架通过web.xml配置404 500错误导向页

    总不能用户输错了url就弹 这玩意吧? <error-page> <error-code>404</error-code> <location>/WEB ...

  10. solr问题missing content stream

    在使用solrj建立索引的时候,报错:missing content stream; 原因在于 HttpSolrServer httpSolrServer = new HttpSolrServer(s ...