题意:

有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(签到)的更多相关文章

  1. 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 ...

  2. A - New Building for SIS

    You are looking at the floor plan of the Summer Informatics School's new building. You were tasked w ...

  3. 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 ...

  4. CF-503div2-A/B/C

    A. New Building for SIS time limit per test 1 second memory limit per test 256 megabytes input stand ...

  5. Codeforces Round #503 Div. 2

    时间相对来说还是比较合适的,正好放假就可以打一打啦. A. New Building for SIS:http://codeforces.com/contest/1020/problem/A 题意概述 ...

  6. hdu 5538 House Building(长春现场赛——水题)

    题目链接:acm.hdu.edu.cn/showproblem.php?pid=5538 House Building Time Limit: 2000/1000 MS (Java/Others)   ...

  7. C#开发微信门户及应用(39)--使用微信JSSDK实现签到的功能

    随着微信开逐步开放更多JSSDK的接口,我们可以利用自定义网页的方式来调用更多微信的接口,实现我们更加丰富的界面功能和效果,例如我们可以在页面中调用各种手机的硬件来获取信息,如摄像头拍照,GPS信息. ...

  8. Building the Testing Pipeline

    This essay is a part of my knowledge sharing session slides which are shared for development and qua ...

  9. 用NSCalendar和UICollectionView自定义日历,并实现签到显示

    前一段时间因为工作需要实现了一个可以签到的日历,来记录一下实现的思路 效果如图:   这里的基本需求是: 1,显示用户某个月的签到情况,已经签到的日子打个圈,没有签到且在某个时间范围内的可以签到,其他 ...

随机推荐

  1. tomcat - 自带日志的区分

    在tomcat 中,logs文件夹下会存放着一些tomcat自带的日志文件,其中有三种文件: 1 > localhost_access_log.2017-12-28 文件,它用来记录tomcat ...

  2. java基础—equals方法

    一.equals方法介绍 1.1.通过下面的例子掌握equals的用法 1 package cn.galc.test; 2 3 public class TestEquals { 4 public s ...

  3. c3p0,dbcp和proxool

    关于c3p0.dbcp和proxool,之类的比较,配置在网上有很多的文章,我这边就不浪费大家的时间了,主要讲下我用过这三个之后的体会. dbcp:框架以前使用的是dbcp,网上说,有很多BUG,至少 ...

  4. jq 下拉框

    <div class="alls"> <div class="item"> <div class="all"& ...

  5. 洛谷 P3601 签到题

    https://www.luogu.org/problemnew/show/P3601 一道关于欧拉函数的题. 读完题目以后我们知道所谓的$aindao(x)=x- \phi (x) $. 对于x小的 ...

  6. HashMap与ArrayMap(和SparseArray)的比较与选择

    HashMap与ArrayMap(和SparseArray)的比较与选择 2017年12月26日 06:04:38 阅读数:61 标签: androidjavahashmaparraymap数据结构 ...

  7. Golang ioutil读写文件测试

    运用 ioutil.ReadFile .ioutil.WriteFile package main import ( "io/ioutil" "log" &qu ...

  8. The 2018 ACM-ICPC Chinese Collegiate Programming Contest Caesar Cipher

    #include <iostream> #include <cstdio> #include <cstring> #include <string> # ...

  9. LA 7049 Galaxy 枚举

    题意: \(x\)轴上有\(n\)个质量为\(1\)的点,他们的坐标分别为\(x_i\). 质心的坐标为\(\frac{\sum{x_i}} {n}\) 转动惯量为\(\sum{d_i^2}\),其中 ...

  10. UVa 10723 LCS变形 Cyborg Genes

    题解转自: UVA 10723 Cyborg Genes - Staginner - 博客园 首先这个题目肯定是按最长公共子序列的形式进行dp的,因为只有保证消去的一部分是最长公共子序列才能保证最后生 ...