UVaLive 7267 Mysterious Antiques in Sackler Museum (if-else,枚举)
题意:给定四个矩形,要求从中选出三个,能不能拼成一个矩形。
析:说到这个题,我还坑了队友一次,读题读错了,我直接看的样例,以为是四个能不能组成,然后我们三个就拼命想有什么简便方法,后来没办法了,直接暴力。
康神写了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,枚举)的更多相关文章
- 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 ...
- 【hihocoder1255 Mysterious Antiques in Sackler Museum】构造 枚举
2015北京区域赛现场赛第2题. 题面:http://media.hihocoder.com/contests/icpcbeijing2015/problems.pdf OJ链接:http://hih ...
- Mysterious Antiques in Sackler Museum(判断长方形)
题目链接 参考博客Ritchie丶的博客 - UVALive 7267 Mysterious Antiques in Sackler Museum (判断长方形) 题意:大概意思就是判断四个矩形能不能 ...
- hiho1255 Mysterious Antiques in Sackler Museum
题目链接:http://media.hihocoder.com/contests/icpcbeijing2015/problems.pdf 题目大意:给你四个矩形,判断是否能取其中任意三个组成一个大矩 ...
- 2015北京区域赛 Mysterious Antiques in Sackler Museum 几何基础+思维
题意是,选出三个,看看是否可以凑成一个新的矩形. #include<bits/stdc++.h> using namespace std; struct node { ]; }a[]; b ...
- 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 ...
- 院校-美国:哈佛大学(Harvard University)
ylbtech-院校-美国:哈佛大学(Harvard University) 哈佛大学(Harvard University),简称“哈佛”,坐落于美国马萨诸塞州波士顿都市区剑桥市,是一所享誉世界的私 ...
- UVALive 4123 Glenbow Museum (组合数学)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud 易得,当n为奇数或者n<3时,答案为0,否则该序列中必定有(n+4)/2个R ...
- 【暑假】[实用数据结构]UVAlive 4670 Dominating Patterns
UVAlive 4670 Dominating Patterns 题目: Dominating Patterns Time Limit: 3000MS Memory Limit: Unkn ...
随机推荐
- poj 2115 C Looooops(扩展gcd)
题目链接 这个题犯了两个小错误,感觉没错,结果怒交了20+遍,各种改看别人题解,感觉思路没有错误,就是wa. 后来看diccuss和自己查错,发现自己的ecgcd里的x*(a/b)写成了x*a/b.还 ...
- 函数xdes_set_bit
/**********************************************************************//** Sets a descriptor bit of ...
- HDU 1358 (所有前缀中的周期串) Period
题意: 给出一个字符串,在所有长度大于1的前缀中,求所有的周期至少为2的周期串,并输出一个周期的长度以及周期的次数. 分析: 有了上一题 HDU 3746 的铺垫,这道题就很容易解决了 把next求出 ...
- 转:MVC3系列:~Html.BeginForm与Ajax.BeginForm
Html.BeginForm与Ajax.BeginForm都是MVC架构中的表单元素,它们从字面上可以看到区别,即Html.BeginForm是普通的表单提交,而Ajax.BeginForm是支持异步 ...
- 【转】Android Studio系列教程一--下载与安装
原文网址:http://stormzhang.com/devtools/2014/11/25/android-studio-tutorial1/ 背景 相信大家对Android Studio已经不陌生 ...
- 在Android应用中使用Clean架构
自从开始开发安卓应用,我一直感觉我可以做得更好.我看过不少烂代码,其中当然有我写的.安卓系统的复杂性加上烂代码势必酿成灾祸,所以从错误中成长就很重要.我Google了如何更好地开发应用,发现了这个叫做 ...
- Ruby 文件处理
#r read, #w write, #a append, #r+ 读写方式 从文件的头位置开始读取或写入, #w+ 读写方式,如果文件已存在清空该文件,不存在就创建一个新的文件, #a+ 如果文件存 ...
- CSS的伪元素(二)
随便聊聊CSS的伪元素,虽然它们在项目开发中用的并不多,但确实很有用,在项目中不用它,是因为大家不能了解它们,下面是一个工作场景,如有四个按钮,分别是建立,编辑,删除和修改,而我们要求这在前台显示的汉 ...
- 组以逗号分隔的子串及跨平update join
下列语句可以对组以逗号分隔的子串 set @device_cd_array += ', ' set @device_cd_array += @nodeid ,, '') update时要join表要先 ...
- 不重启mysql情况修改参数变量
地球人都知道,更新mysql配置my.cnf需要重启mysql才能生效,但是有些时候mysql在线上,不一定允许你重启,这时候应该怎么办呢? 看一个例子: 1 2 3 4 5 6 7 8 9 10 m ...