题意:给定四个矩形,要求从中选出三个,能不能拼成一个矩形。

析:说到这个题,我还坑了队友一次,读题读错了,我直接看的样例,以为是四个能不能组成,然后我们三个就拼命想有什么简便方法,后来没办法了,直接暴力。

康神写了6000多B的代码,全是循环和if-else,我们画出五种情况。。。。然而并不是这样,

只要几个if-else就够,因为就3个,两种情况。

代码如下;

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
using namespace std ; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;
const int dr[] = {0, 0, -1, 1};
const int dc[] = {-1, 1, 0, 0};
int n, m;
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
}
P a[4]; bool judge(int i, int j, int k){
if(a[i].first == a[j].first && a[i].first == a[k].first) return true;
if(a[i].first == a[j].first && a[i].first == a[k].second) return true;
if(a[i].first == a[j].second && a[i].first == a[k].first) return true;
if(a[i].first == a[j].second && a[i].first == a[k].second) return true; if(a[i].second == a[j].first && a[i].second == a[k].first) return true;
if(a[i].second == a[j].first && a[i].second == a[k].second) return true;
if(a[i].second == a[j].second && a[i].second == a[k].first) return true;
if(a[i].second == a[j].second && a[i].second == a[k].second) return true; if(a[i].first == a[j].first + a[k].first && a[j].second == a[k].second) return true;
if(a[i].first == a[j].first + a[k].second && a[j].second == a[k].first) return true;
if(a[i].first == a[j].second + a[k].second && a[j].first == a[k].first) return true;
if(a[i].first == a[j].second + a[k].first && a[j].first == a[k].second) return true; if(a[i].second == a[j].first + a[k].first && a[j].second == a[k].second) return true;
if(a[i].second == a[j].first + a[k].second && a[j].second == a[k].first) return true;
if(a[i].second == a[j].second + a[k].second && a[j].first == a[k].first) return true;
if(a[i].second == a[j].second + a[k].first && a[j].first == a[k].second) return true;
return false;
} int main(){
int T; cin >> T;
while(T--){
for(int i = 0; i < 4; ++i){
scanf("%d %d", &a[i].first, &a[i].second);
}
bool ok = false;
for(int i = 0; i < 4; ++i)
for(int j = 0; j < 4; ++j){
if(i == j) continue;
for(int k = 0; k < 4; ++k){
if(k == i || k == j) continue;
if(judge(i, j, k)) ok = true;
}
}
if(ok) puts("Yes");
else puts("No");
}
return 0;
}

UVaLive 7267 Mysterious Antiques in Sackler Museum (if-else,枚举)的更多相关文章

  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. Mysterious Antiques in Sackler Museum(判断长方形)

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

  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. Gym 101194L / UVALive 7908 - World Cup - [三进制状压暴力枚举][2016 EC-Final Problem L]

    题目链接: http://codeforces.com/gym/101194/attachments https://icpcarchive.ecs.baylor.edu/index.php?opti ...

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

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

  8. UVALive 4123 Glenbow Museum (组合数学)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud 易得,当n为奇数或者n<3时,答案为0,否则该序列中必定有(n+4)/2个R ...

  9. 【暑假】[实用数据结构]UVAlive 4670 Dominating Patterns

    UVAlive 4670 Dominating Patterns 题目:   Dominating Patterns   Time Limit: 3000MS   Memory Limit: Unkn ...

随机推荐

  1. IT玄幻小说

    职业 设计:菜鸟  美工<初级,中级,高级,资深>  设计师<初级,中级,高级,资深>  大神 前端:菜鸟  前端<初级,中级,高级,资深> 架构师<初级,中 ...

  2. windows2003 IIS6网络负载平衡设置

    问题 随着计算机技术的不断发展,单台计算机的性能和可靠性越来越高.但现实中还是有许多应用是单台计算机难以达到,例如: 1.银行存储用户数据的数据库服务器必须保证24小时不间断的运转,并在发生严重硬件故 ...

  3. Java [Leetcode 225]Implement Stack using Queues

    题目描述: Implement the following operations of a stack using queues. push(x) -- Push element x onto sta ...

  4. Xcode中如何启用或禁用某些文件的ARC

    经常会有工程中涉及到第三方的代码, 但这些代码有的是ARC的, 有的不是. 这样的话, 在与你的工程中集成的时候就会出现问题. 如果你的工程是开启ARC的, 那就需要对某些文件禁用ARC, (-fno ...

  5. jquery仿邮箱文本输入框自动加载邮箱后缀

    在像百度这样的网站注册时,你会看到输入邮箱会出现自动给用户输入补全主流邮箱.这种对于增加用户体验的小例子已司空见惯.正好看到人家写的这种js功能.还挺不错,使用起来很方便,几乎不用写神呢代码.&quo ...

  6. MySQL 索引详解

    本文介绍了数据库索引,及其优.缺点.针对MySQL索引的特点.应用进行了详细的描述.分析了如何避免MySQL无法使用,如何使用EXPLAIN分析查询语句,如何优化MySQL索引的应用. 索引是一种特殊 ...

  7. HDU 1387 Team Queue

    Team Queue Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  8. [Everyday Mathematics]20150129

    计算下列积分 $$\bex \int_a^b (x-a)^2(b-x)^3\rd x. \eex$$

  9. [Everyday Mathematics]20150125

    试求极限 $$\bex \lim_{x\to 0^+}\int_x^{2x} \frac{\sin^m t}{t^n}\rd t\quad\sex{m,n\in\bbN}. \eex$$

  10. iBatis 和MyBatis区别

    从  iBatis  到  MyBatis ,你准备好了吗? 对于从事 Java EE 的开发人员来说,iBatis 是一个再熟悉不过的持久层框架了,在 Hibernate.JPA 这样的一站式对象 ...