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 ...
随机推荐
- 对于GLM的理解,与方差分析的对比
最近遇到一个问题,如果因变量为一个连续变量(如胰岛素水平),主要考察的变量为分组变量(如正常血糖组,前糖尿病组,糖尿病组三组),现在的目的是想看调整多种变量(包括多个连续性变量和分类变量)后,胰岛素水 ...
- 常用的PL/SQL开发原则
(1)广泛使用绑定变量,特别是批量绑定,因为这可以有效的避免sql的硬解析和PL/SQL引擎和SQL引擎的上下文切换!(2)广泛使用UROWID来处理DML语句(UROWID是ROWID扩展,ORAC ...
- java运用FFMPEG视频转码技术
基于windows系统安装FFMPEG转码技术 http://wenku.baidu.com/link?url=z4Tv3CUXxxzLpa5QPI-FmfFtrIQeiCYNq6Uhe6QCHkU- ...
- 原生Ajax书写
1.创建XMLHttpRequest对象 function createXMLHTTPRequest() { //1.创建XMLHttpRequest对象 //这是XMLHttpReuquest对象无 ...
- Oracle 课程七之分析和动态采样
课程目标 完成本课程的学习后,您应该能够: •引子—统计信息的作用 •如何收集统计信息 •系统统计信息 •对象统计信息—表.字段.索引统计信息 •动态采样 统计信息的作用 Optimizer st ...
- Dev gridControl 添加表标题
1.OptionsView ->ShowViewCaption = True 2.ViewCaption = "标题"
- 《C++ primer》--第三章
习题3.2 什么是默认构造函数? 解答: 默认构造函数就是在没有显示提供初始化式时调用的构造函数.它由不带参数的构造函数,或者为所有形参提供默认实参的构造函数定义.如果定义某个类的变量时没有提供初始化 ...
- 10、TV UI
TV UI布局 1. 为大屏幕提供适当的布局源文件. 2. 确保UI在一定距离仍然可以看清. 3. 为高清电视提供高分辨率的图标和图像. 1. 把屏幕上的导航控制菜单放在屏幕的左边或者右边,并且将 ...
- SQL合并时间段的问题
假设表结构如下所示: Tsheets 字段名 字段类型 约束 id CHAR(10) PRIMARY KEY start_date DATE CHECK(start_date<= end_dat ...
- 【跟我一起学Python吧】Python的包管理工具
刚开始学习Python时,在看文档和别人的blog介绍安装包有的用easy_install, setuptools, 有的使用pip,distribute,那麽这几个工具有什么关系呢,看一下下面这个图 ...