【Educational Codeforces Round 36 B】Browser
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
分类在区间里面和左边、右边三种情况。
看看l的左边有没有标签、r的右边有没有标签。
就能做完了。
【代码】
#include <bits/stdc++.h>
using namespace std;
int n,pos,l,r;
int main(){
#ifdef LOCAL_DEFINE
freopen("rush_in.txt", "r", stdin);
#endif
ios::sync_with_stdio(0),cin.tie(0);
cin >> n >> pos >>l>>r;
int temp1 = 1000,temp2 = 1000;
if (r!=n){
temp2 = r-pos;
}
if (l!=1){
temp1 = pos-l;
}
if (l<=pos&&pos<=r){
if (temp1==1000 && temp2==1000) return cout<<0<<endl,0;
int ans;
if (temp1!=1000 && temp2!=1000){
ans = min(temp1,temp2) + r-l;
ans++;ans++;
}else{
ans = min(temp1,temp2);
ans++;
}
cout << ans << endl;
}else{
int ans = 0;
if (pos>r){
ans+=pos-r;
ans++;
if (temp1!=1000){
ans+=r-l;
ans++;
}
}else{//pos<l
ans+=l-pos;
ans++;
if (temp2!=1000){
ans+=r-l;
ans++;
}
}
cout << ans << endl;
}
return 0;
}
【Educational Codeforces Round 36 B】Browser的更多相关文章
- 【Educational Codeforces Round 36 D】 Almost Acyclic Graph
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 找到任意一个环. 然后枚举删掉其中的某一条边即可. (因为肯定要删掉这个环的,那么方法自然就是删掉其中的某一条边 (其它环,如果都包 ...
- 【Educational Codeforces Round 36 C】 Permute Digits
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] //从大到小枚举第i(1..len1)位 //剩余的数字从小到大排序. //看看组成的数字是不是小于等于b //如果是的话. //说 ...
- 【Educational Codeforces Round 36 A】 Garden
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 枚举用哪一个桶就好 [代码] #include <bits/stdc++.h> using namespace std; ...
- 【Educational Codeforces Round 37 F】SUM and REPLACE
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 那个D函数它的下降速度是很快的. 也就是说到最后他会很快的变成2或者1 而D(2)==2,D(1)=1 也就是说,几次操作过后很多数 ...
- 【Educational Codeforces Round 37 E】Connected Components?
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] bfs. 用一个链表来记录哪些点已经确定在某一个联通快里了. 一开始每个点都能用. 然后从第一个点开始进行bfs. 然后对于它的所有 ...
- 【Educational Codeforces Round 37 C】 Swap Adjacent Elements
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然l..r这一段连续的1可以把l..r+1变成有序的. 那么就把所有的连续1段变成有序的就好. 看看最后是不是升序即可. [代码] ...
- 【Educational Codeforces Round 37 B】 Tea Queue
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 用一个队列来模拟排队就好. 队列放三元组(x,y,z) x表示人的下标,y和z分别表示进入和退出时间. 然后枚举时间从1到5000 ...
- 【Educational Codeforces Round 37 A】 Water The Garden
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 记录下水龙头在哪些位置. 然后每秒钟把index-i和index+i改变状态一下就好(置1 [代码] #include <bi ...
- 【Educational Codeforces Round 35 D】Inversion Counting
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 排列中交换任意两个数字. 排列的逆序对个数的奇偶性会发生变化. 翻转这个过程其实就是len/2对数字发生交换. 交换了偶数次的话,不 ...
随机推荐
- Java面向切面原理与实践
Java面向切面原理与实践 一. 面向切面编程是什么 首先用一句话概括:面向切面编程(AOP)就是对某些具有相似点的代码进行增强. 相似点可以是同一个包.使用相同的注解.public的方法.以Impl ...
- Spring MVC数据转换
样例:把一个字符串封装而一个对象. 如:username:password格式的数据ZhangSan:1234.我们把这个数据封装成一个User对象.以下分别使用属性编辑器与转换器来实现. 1.自己定 ...
- thinkphp5项目--企业单车网站(五)
thinkphp5项目--企业单车网站(五) 项目地址 fry404006308/BicycleEnterpriseWebsite: Bicycle Enterprise Websitehttps:/ ...
- 1.Apache Axis配置文件WSDD详解
转自:https://jyao.iteye.com/blog/1285516 1. Aapche Axis的Web Service Deployment Descriptor(WSDD)文件参考文档. ...
- POJ 1610 Count the Colors
Count the Colors Time Limit: 2 Seconds Memory Limit: 65536 KB Painting some colored segments on ...
- 联想杨天 S4130-12 win10改win7 bios参数设置
一.进入bios 开机后按 F1 二.改bion参数 1.移动到 save& Exit ,修改 OS optimized defaults 为“Disbled” 再 “F9” 保存 2. ...
- React开发实时聊天招聘工具 -第六章 登陆注册(2)
1.bodyParser和cookieParser: const bodyParser = require('body-parser') const cookieParser = require( ...
- ES6学习笔记(八)第七种类型Symbol
1.概述 ES5 的对象属性名都是字符串,这容易造成属性名的冲突.比如,你使用了一个他人提供的对象,但又想为这个对象添加新的方法(mixin 模式),新方法的名字就有可能与现有方法产生冲突.如果有一种 ...
- 使用scatter画散点图
刚开始接触Python,照着例子写的代码,百度注释的. from numpy import * import matplotlib import matplotlib.pyplot as plt im ...
- CSUOJ 1635 Restaurant Ratings
1635: Restaurant Ratings Time Limit: 1 Sec Memory Limit: 128 MB Description A famous travel web sit ...