【CF1020A】New Building for SIS(签到)
题意:
有n栋楼,从一栋楼某个地方,到大另一栋楼的某个地方,每栋楼给了连接楼的天桥,每走一层或者穿个一栋楼花费一分钟,求出起点到大目的点最少花费的时间
n,h<=1e8,q<=1e4
思路:分类讨论
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef vector<int> VI;
#define fi first
#define se second
#define MP make_pair
#define N 1100000
#define MOD 1000000007
#define eps 1e-8
#define pi acos(-1) int read()
{
int v=,f=;
char c=getchar();
while(c<||<c) {if(c=='-') f=-; c=getchar();}
while(<=c&&c<=) v=(v<<)+v+v+c-,c=getchar();
return v*f;
} void swap(int &x,int &y)
{
int t=x;x=y;y=t;
} int main()
{
//freopen("1.in","r",stdin);
//freopen("1.out","w",stdout);
int n,h,a,b,k;
scanf("%d%d%d%d%d",&n,&h,&a,&b,&k);
for(int i=;i<=k;i++)
{
int x1,y1,x2,y2;
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
int ans=<<;
ans=min(ans,abs(a-y1)+abs(x1-x2)+abs(a-y2));
ans=min(ans,abs(b-y1)+abs(x1-x2)+abs(b-y2));
if(a<=y1&&y1<=b) ans=min(ans,abs(x2-x1)+abs(y1-y2));
if(a<=y2&&y2<=b) ans=min(ans,abs(x2-x1)+abs(y1-y2));
if(x1==x2) ans=min(ans,abs(y1-y2));
printf("%d\n",ans);
}
【CF1020A】New Building for SIS(签到)的更多相关文章
- A. New Building for SIS Codeforce
You are looking at the floor plan of the Summer Informatics School's new building. You were tasked w ...
- A - New Building for SIS
You are looking at the floor plan of the Summer Informatics School's new building. You were tasked w ...
- Codeforces Round #503 (by SIS, Div. 2) Solution
从这里开始 题目列表 瞎扯 Problem A New Building for SIS Problem B Badge Problem C Elections Problem D The hat P ...
- CF-503div2-A/B/C
A. New Building for SIS time limit per test 1 second memory limit per test 256 megabytes input stand ...
- Codeforces Round #503 Div. 2
时间相对来说还是比较合适的,正好放假就可以打一打啦. A. New Building for SIS:http://codeforces.com/contest/1020/problem/A 题意概述 ...
- hdu 5538 House Building(长春现场赛——水题)
题目链接:acm.hdu.edu.cn/showproblem.php?pid=5538 House Building Time Limit: 2000/1000 MS (Java/Others) ...
- C#开发微信门户及应用(39)--使用微信JSSDK实现签到的功能
随着微信开逐步开放更多JSSDK的接口,我们可以利用自定义网页的方式来调用更多微信的接口,实现我们更加丰富的界面功能和效果,例如我们可以在页面中调用各种手机的硬件来获取信息,如摄像头拍照,GPS信息. ...
- Building the Testing Pipeline
This essay is a part of my knowledge sharing session slides which are shared for development and qua ...
- 用NSCalendar和UICollectionView自定义日历,并实现签到显示
前一段时间因为工作需要实现了一个可以签到的日历,来记录一下实现的思路 效果如图: 这里的基本需求是: 1,显示用户某个月的签到情况,已经签到的日子打个圈,没有签到且在某个时间范围内的可以签到,其他 ...
随机推荐
- android 通过adb 和 ndk调试堆栈
打开终端 , 输入以下命令, armeabi是应用编译好的.so库的路径 adb logcat|ndk-stack -sym ./armeabi/ 如果堆栈报错,会弹出报错内容. 如下: C:\Use ...
- mysql 主从数据校验
使用工具pt-table-checksum: /usr/bin/pt-table-checksum --user=root --password='mysqlpass' --host=127.0.0. ...
- Python pip 使用国内镜像
## 推荐源```https://mirrors.aliyun.com/pypi/simple/ 阿里镜像,速度快.稳定https://pypi.douban.com/simple/ 豆瓣镜像```# ...
- 万门大学Python零基础10天进阶班视频教程
点击了解更多Python课程>>> 万门大学Python零基础10天进阶班视频教程 课程简介: 旨在通过两周的学习,让学生不仅能掌握python编程基础从而进行计算机程序的开发, 还 ...
- Python基础——概述
新建Python代码 Jupyter Notebook是在浏览器中运行的. 地址栏输入http://localhost:8888后直接进入工作文件夹,显示文件夹中的内容. 右上角选择New——Pyth ...
- Mac中文乱码问题
在终端切换到文档所在的目录,输入下面的命令: iconv -c -f GB2312 -t UTF-8 乱码的文件名 >> 新文件的名称
- LeetCode(165) Compare Version Numbers
题目 Compare two version numbers version1 and version2. If version1 > version2 return 1, if version ...
- poj 3280 回文字符串问题 dp算法
题意:给一个字符串,构成回文(空也是回文) 其中增删都需要代价.问:代价最少? 思路:把字符串s变空 dp[i][j]表示变成回文的最小代价 for(i=m-1;i>=0;--i) ...
- AD转换器的参数介绍
分辨率.参考电压这些地球人都知道的就不说了. 当“参考电压”和“分辨率”被确定后,每两个数值间的差值,即“步进量”. 上面的“步进量”在AD中称为1LSB(最低有效位,Least Significan ...
- UVa 1407 树形背包 Caves
这道题可以和POJ 2486 树形背包DP Apple Tree比较着来做. 参考题解 #include <iostream> #include <cstdio> #inclu ...