[枚举] HDU 2019 Multi-University Training Contest 8 - Calabash and Landlord
Calabash and Landlord
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 3228 Accepted Submission(s): 613
One
day the landlord set up two orthogonal rectangular-shaped fences on his
land. He asked Calabash a simple problem: how many nonempty connected
components is my land divided into by these two fences, both finite and
infinite? Calabash couldn't answer this simple question. Please help
him!
Recall that a connected component is a maximal set of
points not occupied by the fences, and every two points in the set are
reachable without crossing the fence.
Each test case contains two lines, specifying the two rectangles. Each line contains four integers x1,y1,x2,y2 (0≤x1,y1,x2,y2≤109,x1<x2,y1<y2), where (x1,y1),(x2,y2)
are the Cartesian coordinates of two opposite vertices of the
rectangular fence. The edges of the rectangles are parallel to the
coordinate axes. The edges of the two rectangles may intersect, overlap,
or even coincide.
0 0 1 1
2 2 3 4
1 0 3 2
0 1 2 3
0 0 1 1
0 0 1 1
4
2
题意:给你2个栅栏的坐标,栅栏会分割平面,问栅栏分割平面后有多少个连通块
思路:枚举所有情况,时间复杂度O(1),代码复杂度O(∞),一开始WA到自闭,就开始暴力模式,写的时候懵了,出现了一些难以发现的小错误,差点翻车,最后15分钟才改出来,
所有情况都在代码里了,可以看一下代码,这里就不细讲了
#include<bits/stdc++.h>
using namespace std;
int x_1[],y_1[],x_2[],y_2[];
int main(){
int t,a,b;
ios::sync_with_stdio();
cin>>t;
while(t--){
for(int i=;i<=;i++)cin>>x_1[i]>>y_1[i]>>x_2[i]>>y_2[i];
a=,b=;
if(x_1[]>x_1[])a^=,b^=;
if(x_1[]==x_1[]){
if(x_2[b]>x_2[a]||y_2[b]>y_2[a]||y_1[b]<y_1[a])a^=,b^=;
}
if(x_1[a]==x_1[b]&&x_2[a]==x_2[b]&&y_1[a]==y_1[b]&&y_2[a]==y_2[b]){
cout<<<<endl;
}
else{
if(x_2[a]<=x_1[b]){
cout<<<<endl;
}
else{
if(y_2[a]<=y_1[b]||y_1[a]>=y_2[b]){
cout<<<<endl;
}
else{
if(x_1[a]==x_1[b]){ ///l1
if(x_2[a]==x_2[b]){ ///r1
if(y_1[a]==y_1[b]){ ///d1
if(y_2[a]==y_2[b]) ///u1
cout<<<<endl;
else
cout<<<<endl;
}
else{ ///d0
if(y_2[a]==y_2[b]) ///u1
cout<<<<endl;
else ///u0
cout<<<<endl;
}
}
else if(x_2[b]>x_2[a]){ ///l1 r0
if(y_1[a]==y_1[b]){ ///d1
if(y_2[a]==y_2[b]||y_2[a]<y_2[b])
cout<<<<endl;
else if(y_2[a]>y_2[b])
cout<<<<endl;
}
else{ ///d0
if(y_1[a]<y_1[b]){
if(y_2[a]==y_2[b])cout<<<<endl;
else if(y_2[a]>y_2[b]) cout<<<<endl;
else cout<<<<endl;
}
else{
if(y_2[a]==y_2[b])cout<<<<endl;
else if(y_2[a]>y_2[b]) cout<<<<endl;
else cout<<<<endl;
}
}
}
else{
if(y_1[a]==y_1[b]){ ///d1
if(y_2[a]==y_2[b]||y_2[a]>y_2[b])
cout<<<<endl;
else if(y_2[a]<y_2[b])
cout<<<<endl;
}
else{ ///d0
if(y_1[a]>y_1[b]){
if(y_2[a]==y_2[b])cout<<<<endl;
else if(y_2[a]>y_2[b]) cout<<<<endl;
else cout<<<<endl;
}
else{
if(y_2[a]==y_2[b])cout<<<<endl;
else if(y_2[a]>y_2[b]) cout<<<<endl;
else cout<<<<endl;
}
}
}
}
else{
if(x_2[a]==x_2[b]){ ///l0 r1
if(y_1[a]==y_1[b]){
if(y_2[a]==y_2[b])
cout<<<<endl;
else if(y_2[a]>y_2[b])cout<<<<endl;
else cout<<<<endl;
}
else{
if(y_1[a]<y_1[b]){
if(y_2[a]==y_2[b]||y_2[a]>y_2[b])cout<<<<endl;
else cout<<<<endl;
}
else{
if(y_2[a]==y_2[b]||y_2[a]>y_2[b])cout<<<<endl;
else cout<<<<endl;
}
}
}
else{
if(x_2[a]>x_2[b]){
if(y_1[a]==y_1[b]){
if(y_2[a]==y_2[b])cout<<<<endl;
else if(y_2[a]>y_2[b])cout<<<<endl;
else cout<<<<endl;
}
else{
if(y_1[a]<y_1[b]){
if(y_2[a]==y_2[b]||y_2[a]>y_2[b])cout<<<<endl;
else cout<<<<endl;
}
else{
if(y_2[a]==y_2[b])cout<<<<endl;
else if(y_2[a]>y_2[b])cout<<<<endl;
else cout<<<<endl;
}
}
}
else{
if(y_1[a]==y_1[b]){
cout<<<<endl;
}
else{
if(y_1[a]<y_1[b]){
cout<<<<endl;
}
else{
if(y_2[a]==y_2[b]||y_2[a]>y_2[b])cout<<<<endl;
else cout<<<<endl;
}
}
}
}
}
}
}
}
} }
[枚举] HDU 2019 Multi-University Training Contest 8 - Calabash and Landlord的更多相关文章
- hdu 4864 Task---2014 Multi-University Training Contest 1
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4864 Task Time Limit: 4000/2000 MS (Java/Others) M ...
- hdu 4937 2014 Multi-University Training Contest 7 1003
Lucky Number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) T ...
- hdu 4946 2014 Multi-University Training Contest 8
Area of Mushroom Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- HDU 6395 2018 Multi-University Training Contest 7 (快速幂+分块)
原题地址 Sequence Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)T ...
- hdu 4941 2014 Multi-University Training Contest 7 1007
Magical Forest Time Limit: 24000/12000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Other ...
- hdu 4939 2014 Multi-University Training Contest 7 1005
Stupid Tower Defense Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/ ...
- HDU - 6304(2018 Multi-University Training Contest 1) Chiaki Sequence Revisited(数学+思维)
http://acm.hdu.edu.cn/showproblem.php?pid=6304 题意 给出一个数列的定义,a[1]=a[2]=1,a[n]=a[n-a[n-1]]+a[n-1-a[n-2 ...
- hdu 5755 2016 Multi-University Training Contest 3 Gambler Bo 高斯消元模3同余方程
http://acm.hdu.edu.cn/showproblem.php?pid=5755 题意:一个N*M的矩阵,改变一个格子,本身+2,四周+1.同时mod 3;问操作多少次,矩阵变为全0.输出 ...
- hdu 5738 2016 Multi-University Training Contest 2 Eureka 计数问题(组合数学+STL)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5738 题意:从n(n <= 1000)个点(有重点)中选出m(m > 1)个点(选出的点只 ...
随机推荐
- Android中的路径记录
Android中的路径记录 | RobinBlog 导航 导航 博客 分类 标签 友链 关于 搜索 Environment.getDataDirectory().getPath()=/dataEnvi ...
- JQuery之选择器篇(一)
今天回顾了之前学习的JQuery选择器,现在简单的总结一下. JQuery选择器类型 主要分为四类 基本选择器 层级选择器 过滤选择器 表单选择器 基本选择器 基本选择器是jQuery中最 ...
- tfgan折腾笔记(二):核心函数详述——gan_model族
定义model的函数有: 1.gan_model 函数原型: def gan_model( # Lambdas defining models. generator_fn, discriminator ...
- Implementing 5G NR Features in FPGA
目录 论文来源 论文简介 基本原理 论文创新点 借鉴之处 论文来源 2018 European Conference on Networks and Communications (EuCNC),Ja ...
- 如何看待Java是世界上最好的语言?
Java出现二十多年以来,一直都是主流的开发语言,Java创建于 1995 年,在 20多年的发展历程中,Java 已经证明自己是用于自定义软件开发的顶级通用编程语言. Java 广泛应用于科学教育. ...
- 如何优化自己的JS代码
尽管接触大大小小项目N多个,但是刚入行两年, 撸码还是没有完全成一定的规律:最近受到很多启发,打算沉淀沉淀自己的代码: 之前很多页面的很多js脚本本分代码,更注重效果,事件久后没有发展 性能也是很关键 ...
- 从头认识js-HTML中使用JavaScript
<script>元素 在HTML页面中插入Javascript的主要办法就是使用<script>元素,HTML4.01为<script>定义了下列6个属性. 1.a ...
- 浏览器渲染流程&Composite(渲染层合并)简单总结
梳理浏览器渲染流程 首先简单了解一下浏览器请求.加载.渲染一个页面的大致过程: DNS 查询 TCP 连接 HTTP 请求即响应 服务器响应 客户端渲染 这里主要将客户端渲染展开梳理一下,从浏览器器内 ...
- Python入门的三大问题和三大谎言
Python广告,铺天盖地,小白们雾里看花,Python无限美好.作为会20几种语言(BASIC Foxbase/pro VB VC C C++ c# js typescript HTML Ardui ...
- vue项目npm run dev 报错Uncaught SyntaxError: Unexpected token <
目前代码所处位置是micro分支,该分支是从dev分支直接拉下来进行npm run dev的,而dev分支是可以正常运行的,网上的诸多解释是babel转义时候报错,其实对比可见,两个分支不同的地方应该 ...