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

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

康神写了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. 结构体key

    http://www.cnblogs.com/xpchild/p/3770823.html http://blog.sae.sina.com.cn/archives/3968 实例 http://bl ...

  2. easyui-dialog中文件上传处理

    function openDialog() { // $('#dlg').dialog('open'); //EasyUi的dialog中文件上传,后台获取不到文件,需要改写为下面这样 $(" ...

  3. UVA 10735 Euler Circuit 混合图的欧拉回路(最大流,fluery算法)

    题意:给一个图,图中有部分是向边,部分是无向边,要求判断是否存在欧拉回路,若存在,输出路径. 分析:欧拉回路的定义是,从某个点出发,每条边经过一次之后恰好回到出发点. 无向边同样只能走一次,只是不限制 ...

  4. K2 blackpearl 流程开发(一)

    转:http://blog.csdn.net/gxiangzi/article/details/8444060 郁闷,今天K2的license过期了,很多东西都没法用了,还得去找PM大大帮忙申请一个. ...

  5. 130道ASP.NET面试题

    转:http://boke.25k5.com/kan88569.html 1. 简述 private. protected. public. internal 修饰符的访问权限. 答 . privat ...

  6. git中reset与revert的使用

    http://alpha-blog.wanglianghome.org/2010/07/30/git-partial-rollback/ reset(版本撤回) 格式 git reset [-q] [ ...

  7. 修改Oracle 表空间名称 tablespace name

    修改表空间名称步骤如下: 1. 使用oracle用户登录执行 $sqlplus / as sysdba 2. 执行修改表空间命令如下 SQL> alter tablespace  TEST re ...

  8. 1047图的深度优先遍历c语言

    描述 图(graph)是数据结构 G=(V,E),其中V是G中结点的有限非空集合,结点的偶对称为边(edge):E是G中边的有限集合.设V={0,1,2,……,n-1},图中的结点又称为顶点(vert ...

  9. IDEA与Tomcat创建并运行Java Web项目及servlet的简单实现

    创建Web项目 1. File -> New Project ,进入创建项目窗口 2.在 WEB-INF 目录下点击右键, New -> Directory ,创建  classes 和  ...

  10. delegate 为什么用 weak属性

    weak指针主要用于“父-子”关系,父亲拥有一个儿子的strong指针,因此是儿子的所有者:但是为了阻止所有权回环,儿子需要使用weak指针指向父亲:你的viewcontroller通过strong指 ...