【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对数字发生交换. 交换了偶数次的话,不 ...
随机推荐
- appium使用教程(二)-------------连接手机
1. 安装驱动 说明:如果驱动装不上,可以使用第三方的工具去安装.(一般来说还是用第三方) 大概就是这个样子索. 2. 开启usb调试 1)开发者选项打开(不知道怎么打开的问度娘) 2)开启USB调试 ...
- django-debug-toolbar 使用
https://pypi.org/project/django-debug-toolbar/ https://django-debug-toolbar.readthedocs.io/en/latest ...
- caioj 1086 动态规划入门(非常规DP10:进攻策略)
一开始看到题目感觉很难 然后看到题解感觉这题贼简单,我好像想复杂了 就算出每一行最少的资源(完全背包+二分)然后就枚举就好了. #include<cstdio> #include<a ...
- shiro整合thymeleaf
1.引入依赖 <!--thymeleaf中使用shiro--> <dependency> <groupId>com.github.theborakompanioni ...
- ARM官方《CMSIS-RTOS教程》之线程Threads
创建线程Creating Threads 一旦RTOS开始运行,就会有很多系统调用来管理和控制活跃的线程.默认情况下,main()函数自动被创建为第一个可运行的线程.在第一个例子里我们使用main() ...
- linux学习之多高并发服务器篇(一)
高并发服务器 高并发服务器 并发服务器开发 1.多进程并发服务器 使用多进程并发服务器时要考虑以下几点: 父最大文件描述个数(父进程中需要close关闭accept返回的新文件描述符) 系统内创建进程 ...
- 个人学习源码的 HBase误区的总结 与 架构图
HDFS 的备份功能不是给 基于 HBase 等 基于HDFS 的项目做备份的. 如果 HBase 需要备份,那么久需要设置 备份(快照 )功能. HMaster . kafka 等无主结构并 ...
- Android资源之图像资源(状态图像资源)
在上一篇博文中.我主要解说了XML图像资源中的图层资源,在此图像资源博文中我会给大家陆续解说XMl图像资源的图像状态资源.图像级别资源.淡入淡出资源.嵌入图像资源.剪切图像资源和外形资源. 1.图像状 ...
- MongoDB 基本使用
数据库基本操作 连接到mongoDBserver 1 ./bin/mongo 127.0.0.1:12345 查看当前数据库 1 2 3 > show dbs admin (empty) ...
- 22. Angular 中用 a 标签 href 路由时在浏览器中显示异常 "%2F" 路由失败问题
转自:https://blog.csdn.net/duansale/article/details/77455355 <a href="#/index">index&l ...