2019 杭电多校第八场 HDU - 6665 Calabash and Landlord 两矩形分平面
题意
给出两个矩形,问这两个矩形把平面分成了几部分。
分析
不需要什么高级技能,只需 “简单” 的分类讨论。
(实在太难写了,对拍找出错误都不想改
推荐博客,其中有个很好的思路,即只讨论答案为2,3,5,6的情况,其余都为4,这样可以省掉一些麻烦。
#include <bits/stdc++.h>
using namespace std;
int main() {
int x11, x12, y11, y12;
int x21, x22, y21, y22;
int x1, y1, x2, y2;
int T;
scanf("%d", &T);
while(T--) {
scanf("%d %d %d %d %d %d %d %d", &x11, &y11, &x12, &y12, &x21, &y21, &x22, &y22);
if(x11 == x21 && x12 == x22 && y11 == y21 && y12 == y22) {
printf("2\n");
continue;
}
if(x12 <= x21 || x22 <= x11 || y12 <= y21 || y22 <= y11) {
printf("3\n");
continue;
} if((x11 > x21 && x12 < x22 && y11 > y21 && y12 < y22) || (x11 < x21 && x12 > x22 && y11 < y21 && y12 > y22)) {
printf("3\n");
continue;
}
//
if((x11 == x21 && y11 >= y21 && x12 < x22 && y12 <= y22) || (x11 == x21 && y11 <= y21 && x12 > x22 && y12 >= y22)) {
printf("3\n");
continue;
}
if((x11 > x21 && y11 >= y21 && x12 == x22 && y12 <= y22) || (x11 < x21 && y11 <= y21 && x12 == x22 && y12 >= y22)) {
printf("3\n");
continue;
}
if((x11 >= x21 && y11 == y21 && x12 <= x22 && y12 < y22) || (x11 <= x21 && y11 == y21 && x12 >= x22 && y12 > y22)) {
printf("3\n");
continue;
}
if((x11 >= x21 && y11 > y21 && x12 <= x22 && y12 == y22) || (x11 <= x21 && y11 < y21 && x12 >= x22 && y12 == y22)) {
printf("3\n");
continue;
} if((x11 > x21 && y11 < y21 && x12 < x22 && y12 > y22) || (x11 < x21 && y11 > y21 && x12 > x22 && y12 < y22)) {
printf("6\n");
continue;
} if((x12 < x22 && y12 == y22 && x11 > x21 && y11 < y21) || (x12 > x22 && y12 == y22 && x11 < x21 && y11 > y21)) {
printf("5\n");
continue;
}
if((x12 < x22 && y12 > y22 && x11 > x21 && y11 == y21) || (x12 > x22 && y12 < y22 && x11 < x21 && y11 == y21)) {
printf("5\n");
continue;
} if((x12 == x22 && y12 < y22 && x11 < x21 && y11 > y21) || (x12 == x22 && y12 > y22 && x11 > x21 && y11 < y21)) {
printf("5\n");
continue;
}
if((x12 > x22 && y12 < y22 && x11 == x21 && y11 > y21) || (x12 < x22 && y12 > y22 && x11 == x21 && y11 < y21)) {
printf("5\n");
continue;
} printf("4\n"); }
return ;
}
2019 杭电多校第八场 HDU - 6665 Calabash and Landlord 两矩形分平面的更多相关文章
- [2019杭电多校第八场][hdu6667]Roundgod and Milk Tea
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6667 题目大意是说n个班级,每个班级有ai人和bi杯茶,每个人只能喝其他班的茶并且只能喝一杯.问最多有 ...
- 2019杭电多校第七场 HDU - 6656 Kejin Player——概率&&期望
题意 总共有 $n$ 层楼,在第 $i$ 层花费 $a_i$ 的代价,有 $pi$ 的概率到 $i+1$ 层,否则到 $x_i$($x_i \leq 1$) 层.接下来有 $q$ 次询问,每次询问 $ ...
- Acesrc and Travel(2019年杭电多校第八场06+HDU6662+换根dp)
题目链接 传送门 题意 两个绝顶聪明的人在树上玩博弈,规则是轮流选择下一个要到达的点,每达到一个点时,先手和后手分别获得\(a_i,b_i\)(到达这个点时两个人都会获得)的权值,已经经过的点无法再次 ...
- 杭电多校第八场-A-Character Encoding
题目描述 In computer science, a character is a letter, a digit, a punctuation mark or some other similar ...
- [2019杭电多校第十场][hdu6701]Make Rounddog Happy
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6701 题目大意为求满足 $max(a_{l},a_{l+1}\cdot \cdot \cdot a_{ ...
- [2019杭电多校第七场][hdu6656]Kejin Player
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6656 题意为从i级花费a元有p的概率升到i+1级,有1-p的概率降到x级(x<i),查询从L级升 ...
- [2019杭电多校第七场][hdu6655]Just Repeat
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6655 题意是说两个人都有一些带有颜色的牌,两人轮流出牌,但是不能出对面出过的颜色的牌,最后谁不能出牌谁 ...
- [2019杭电多校第七场][hdu6651]Final Exam
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6651 题意:n个科目,总共m分,通过一科需要复习花费科目分数+1分钟,在不知道科目分数的情况下,问最少 ...
- [2019杭电多校第七场][hdu6646]A + B = C(hash)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6646 题意为求a*10x+b*10y=c*10z满足公式的任意一组解x,y,z. 因为c有可能会由a+ ...
随机推荐
- [转帖]04-创建kubeconfig认证文件
04-创建kubeconfig认证文件 https://www.cnblogs.com/guigujun/p/8366530.html 学习一下 貌似挺有用的. 本文档记录自己的学习历程! 创建 ku ...
- [PDF] - 获取 RadioButtonList 控件值的方法
背景 目标是通过 iTextSharp 读取 PDF 模板,填充内容后以生成新 PDF 文件.利用 福昕PDF编辑器个人版 可以获取到 RadioButtonList 的组名,但是获取不到每一个 Ra ...
- SpringMVC获取参数的几种方式
前言: 年末了,忙了一年了却发现系统的整理的东西很少,一些基础的东西都未做整理,这里就将它随便整理一下,增加一些印象,当然在网上看到一些好的资料也会整理下来以备后用.今天整理一下springMVC获取 ...
- C++ 字符串处理类 ProcessString (包含常用字符串处理函数)
ProcessString.h //Linux & C++11 #pragma once //包含系统头文件 #include <string> #include <sstr ...
- django修改表数据结构后报错的解决办法
1.进入数据库删除app之前创建的表,如果删除有关联的表报错的话可以先删除其他表然后再删除因关联关系删除不了的表 2.删除django_migrations表中对应的app记录,删除命令delete ...
- Python之推导式笔记
观察下面的代码: list1 = [] for i in range(10): list1.append(i) print(list1) 作为一个Java出身的程序员,我一定会这么写代码去生成一个列表 ...
- 【并发】9、借助redis 实现生产消费,消息订阅发布模式队列
这个就是一个消息可以被多次消费的范例了 其实这个实现的方式可以参考我之前的设计模式,观察者模式 https://www.cnblogs.com/cutter-point/p/5249780.html ...
- [Luogu5320][BJOI2019]堪破神机(DP+斯特林数)
https://www.cnblogs.com/cjyyb/p/10747543.html 特征方程+斯特林反演化简式子,要注意在模998244353意义下5没有二次剩余,所以每个数都要用$a+b\s ...
- 解决阿里云OSS The requested bucket name is not available的办法
今天在创建Bucket的时候遇到了这个问题 The requested bucket name is not available. The bucket namespace is shared by ...
- C#-Json-抽象类的反序列化
引用: using System; using System.Collections.Generic; using Newtonsoft.Json; using Newtonsoft.Json.Lin ...