Sackler Museum of Art and Archaeology at Peking University is located on a beautiful site near the West Gate of Peking University campus, and its architecture takes the inspiration from buildings that already exist on campus.

The collection of Chinese art and artifacts currently housed in this new museum contains more than 10, 000 objects and spans a period of 280, 000 years, from Paleolithic hominids and stone tool remains to costumes, ceramics and paintings of the present era. The collection, which is used for teaching and research purposes, has been acquired during the past seventy years from diverse sources.

The use of some objects in the museum remains unknown. For example, there are four pieces of rectangular bones which can be dated back to 200, 000 years ago, and no one knows what they were made for. A former NOIer and present ACMer, Mr. Liang in the School of Archaeology and Museology is very interested in those bones, and his tutor told him to use his wildest imagination to guess the usage of them. So, one day, a crazy idea came up to him: were those bones some kind of IQ test tools used by ancient people? Maybe the one who could pick exactly three pieces of those bones to form a larger rectangle was considered smart at that time. So Mr. Liang wanted to write a program to find out how to pass this IQ test imagined by him. Can you also do this?

Input

There are several test cases. The first line of input is an integer T (1 ≤ T ≤ 20), indicating the number of test cases. Each test case is in one line and contains 8 integers describing 4 rectangular bones. Each bone is described by 2 integers indicating its width and height.

All integers in the input are between [1, 1000].

Output

For each test case, if Mr. Liang can form a rectangle using those bones in the way he imagined, please print ‘Yes’. If he can’t, print ‘No’ instead. Please note that the area of the new rectangle he forms must be equal to the total area of the bones he picks.

Sample Input

2

1 1 1 1 1 2 2 2

1 1 2 2 10 10 20 20

Sample Output

Yes

No

题意:有t组数据,每组给定4个长方形的宽和高,问是否能从中任取三个构成一个严格的长方形,严格的长方形指的是长方形内部没有空缺。

题解:从中任取三个,进行判断即可,写成结构体用函数判断可以大幅减少代码量。

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <map>
#include <vector>
#include <cstring>
using namespace std;
struct D{
int w,h;
D(int w0=,int h0=) {
w = w0;
h = h0;
}
}data[];
D ll(D a,D b){
if(a.w==b.w) return D(a.w,a.h+b.h);
else if(a.h==b.w) return D(a.h,a.w+b.h);
else if(a.h==b.h) return D(a.h,a.w+b.w);
else if(a.w==b.h) return D(a.w,a.h+b.w);
else return D(,);
}
bool pd(D a,D b,D c){
D tmp;
tmp = ll(a,b);
tmp = ll(tmp,c);
if(tmp.w>) return true;
tmp = ll(a,c);
tmp = ll(tmp,b);
if(tmp.w>) return true;
tmp = ll(b,c);
tmp = ll(tmp,a);
if(tmp.w>) return true;
return false;
}
bool solve() {
if(pd(data[],data[],data[])) return true;
if(pd(data[],data[],data[])) return true;
if(pd(data[],data[],data[])) return true;
if(pd(data[],data[],data[])) return true;
return false;
}
int main() {
int T;
scanf("%d",&T);
while(T--) {
for(int i=;i<;i++) {
scanf("%d%d",&data[i].w,&data[i].h);
}
if(solve()) puts("Yes");
else puts("No");
}
}

UVALive 7267 Mysterious Antiques in Sackler Museum (判断长方形)的更多相关文章

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

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

  2. Mysterious Antiques in Sackler Museum(判断长方形)

    题目链接 参考博客Ritchie丶的博客 - UVALive 7267 Mysterious Antiques in Sackler Museum (判断长方形) 题意:大概意思就是判断四个矩形能不能 ...

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

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

  4. hiho1255 Mysterious Antiques in Sackler Museum

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

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

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

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

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

  7. CodeForces 596A

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

  8. 简单几何(判断矩形的位置) UVALive 7070 The E-pang Palace(14广州B)

    题目传送门 题意:给了一些点,问组成两个不相交的矩形的面积和最大 分析:暴力枚举,先找出可以组成矩形的两点并保存起来(vis数组很好),然后写个函数判断四个点是否在另一个矩形内部.当时没有保存矩形,用 ...

  9. UVALive 7281 Saint John Festival (凸包+O(logn)判断点在凸多边形内)

    Saint John Festival 题目链接: http://acm.hust.edu.cn/vjudge/contest/127406#problem/J Description Porto's ...

随机推荐

  1. 【poj3537】 Crosses ans Crosses

    poj.org/problem?id=3537 (题目链接) 题意 给出一个1*n的棋盘,每次可以选择一个没被标记过的点打标记,若经过某一步操作使得出现3个连续的标记,则最后操作的人获胜.问是否存在先 ...

  2. Jfreechart 乱码

    整个图标分成三部分chart   title,chart 的plot还有chart的   legend三个部分需要对他们分别设置字体就对了. 先看解决方法( 把这几个全部设置了,都搞定了就可以了): ...

  3. IDE 集成开发环境

    集成开发环境(IDE,Integrated Development Environment )是用于提供程序开发环境的应用程序,一般包括代码编辑器.编译器.调试器和图形用户界面工具.集成了代码编写功能 ...

  4. soa vs cop

    soa强调分层:底层为高层提供服务: cop强调分块:有明确的职责和服务提供接口,为外部提供服务. SOA 原则非常强调将服务使用者和服务提供者分离开来,关于此类分离实际的含义,有很多不正式但非常有用 ...

  5. mysql union 详解

    Union:作用:把2次或多次查询结果合并起来要求:两次查询的列数一致推荐:查询的每一列,相对应的列类型也一样 可以来自于多张表 多次sql语句取出的列名可以不一致,此时,以第1个sql的列名为准 例 ...

  6. Java统计数据库表中记录数

    public static int count(String txyl_table) {// 获取用户数量 int i = 0;// Store_Information Connection con ...

  7. C# 集合扩展快速排序算法

    /// <summary> /// 对集合进行排序,如 /// List<Person> users=new List<Person>(){.......} /// ...

  8. Java JNI 编程进阶 实例+c++数据类型与jni数据类型转换

    原文:http://www.iteye.com/topic/295776 JNI一直以来都很少去关注,但却是我心中的一个结,最近这几天刚好手头有点时间,因此抽空看了一下这方面的东西,整理了一份文档,J ...

  9. linux查看内核版本、系统版本、系统位数(32or64)

     linux查看内核版本.系统版本.系统位数(32or64) 2011-05-01 22:05:12 标签:linux 内核版本 休闲 系统版本 系统位数 1. 查看内核版本命令: 1) [root@ ...

  10. 机器学习公开课笔记(4):神经网络(Neural Network)——表示

    动机(Motivation) 对于非线性分类问题,如果用多元线性回归进行分类,需要构造许多高次项,导致特征特多学习参数过多,从而复杂度太高. 神经网络(Neural Network) 一个简单的神经网 ...