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+ ...
随机推荐
- qt model--view-delegate模式的界面设计概念,ListView用法
最经典的界面设计模式,必须知道. 作为 一种经典到 不能 再 经典 的 架构 模式, qt的model--view-delegate大 行其 道 有其 必然 的 道理. 通过 把 职责. 性质相近的 ...
- Mysql 千万数据快速导入
最近碰到个项目,需要 千万条数据入库的问题,有原本的 类 csv 文件导入, 统计了下 数据行大概有 1400W 行之多 二话不说, 建表,直接 load LOAD DATA LOCAL INFIL ...
- LeetCode 459. 重复的子字符串(Repeated Substring Pattern)
459. 重复的子字符串 459. Repeated Substring Pattern 题目描述 给定一个非空的字符串,判断它是否可以由它的一个子串重复多次构成.给定的字符串只含有小写英文字母,并且 ...
- 共阳极RGB LED二极管
1)RGB LED二极管有四个引脚,它把3个普通led被封装在其内部,这三个led颜色分别为红.绿.蓝三种颜色,通过控制各个LED的亮度,你可以混合出几乎任何你想要的颜色,如下图: 2)RGB LED ...
- FZU2018级算法第三次作业 3.16 station
题目大意: 给出1-n共n个数的入栈顺序,可以随时出栈,求出栈的最大字典序. 输入示例 输出示例 51 2 3 4 5 5 4 3 2 1 54 2 5 3 1 5 3 2 4 1 题目分析: 假设目 ...
- SQL——UPDATE(改)
一.UPDATE语句基本用法 UPADTE语句用于修改表中已存在的记录. UPDATE语句语法: UPDATE 表名 SET 列名1 = 值1,列名2 = 值2... WHERE 条件语句; 演示st ...
- 米联客 osrc_virtual_machine_sdx2017_4 虚拟机的使用
今天大部分时间都在高csdn的博客的,一直无法和word关联,来不及写使用教程了,先发下载链接. 虚拟机安装的是ubuntu16.4.3,vivado软件是SDX2017.4版本,包括的vivado2 ...
- v8 引擎的内存
一.nodejs查看内容使用情况: process.memoryUsage() 单位为 Btye 转化函数: var format = function(bytes) { return (bytes/ ...
- 为什么要使用Optional
为什么使用Java Optional Why use Optional? NullPointerException 有个很有名的说法: Null Pointer References: The Bil ...
- DropDownList下拉控件
<asp:DropDownList ID="DropDownList1" runat="server" Width="177px" ...