Codeforces Round #384 (Div. 2) A. Vladik and flights 水题
A. Vladik and flights
题目链接
http://codeforces.com/contest/743/problem/A
题面
Vladik is a competitive programmer. This year he is going to win the International Olympiad in Informatics. But it is not as easy as it sounds: the question Vladik face now is to find the cheapest way to get to the olympiad.
Vladik knows n airports. All the airports are located on a straight line. Each airport has unique id from 1 to n, Vladik's house is situated next to the airport with id a, and the place of the olympiad is situated next to the airport with id b. It is possible that Vladik's house and the place of the olympiad are located near the same airport.
To get to the olympiad, Vladik can fly between any pair of airports any number of times, but he has to start his route at the airport a and finish it at the airport b.
Each airport belongs to one of two companies. The cost of flight from the airport i to the airport j is zero if both airports belong to the same company, and |i - j| if they belong to different companies.
Print the minimum cost Vladik has to pay to get to the olympiad.
输入
The first line contains three integers n, a, and b (1 ≤ n ≤ 105, 1 ≤ a, b ≤ n) — the number of airports, the id of the airport from which Vladik starts his route and the id of the airport which he has to reach.
The second line contains a string with length n, which consists only of characters 0 and 1. If the i-th character in this string is 0, then i-th airport belongs to first company, otherwise it belongs to the second.
输出
Print single integer — the minimum cost Vladik has to pay to get to the olympiad.
样例输入
4 1 4
1010
样例输出
1
题意
两个属于相同type的城市的旅游的话,花费为0
不同的花费为1
问你从a到b的最小花费是多少
题解
显然不是1就是0= =
代码
#include<bits/stdc++.h>
using namespace std;
int n,a,b;
string s;
int main()
{
scanf("%d%d%d",&n,&a,&b);
cin>>s;
if(s[a-1]==s[b-1])cout<<"0"<<endl;
else cout<<"1"<<endl;
}
Codeforces Round #384 (Div. 2) A. Vladik and flights 水题的更多相关文章
- Codeforces Round #384 (Div. 2) C. Vladik and fractions 构造题
C. Vladik and fractions 题目链接 http://codeforces.com/contest/743/problem/C 题面 Vladik and Chloe decided ...
- Codeforces Round #297 (Div. 2)A. Vitaliy and Pie 水题
Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec Memory Limit: 256 MBSubmit: xxx ...
- Codeforces Round #290 (Div. 2) A. Fox And Snake 水题
A. Fox And Snake 题目连接: http://codeforces.com/contest/510/problem/A Description Fox Ciel starts to le ...
- Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题
A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...
- Codeforces Round #373 (Div. 2) B. Anatoly and Cockroaches 水题
B. Anatoly and Cockroaches 题目连接: http://codeforces.com/contest/719/problem/B Description Anatoly liv ...
- Codeforces Round #368 (Div. 2) A. Brain's Photos 水题
A. Brain's Photos 题目连接: http://www.codeforces.com/contest/707/problem/A Description Small, but very ...
- Codeforces Round #359 (Div. 2) A. Free Ice Cream 水题
A. Free Ice Cream 题目连接: http://www.codeforces.com/contest/686/problem/A Description After their adve ...
- Codeforces Round #355 (Div. 2) A. Vanya and Fence 水题
A. Vanya and Fence 题目连接: http://www.codeforces.com/contest/677/problem/A Description Vanya and his f ...
- Codeforces Round #384 (Div. 2) E. Vladik and cards 状压dp
E. Vladik and cards 题目链接 http://codeforces.com/contest/743/problem/E 题面 Vladik was bored on his way ...
随机推荐
- 超链接的#和javascript:void(0)的区别
转载于:http://www.uw3c.com/cssviews/css12.html 在工作中,如果我们想把a标签中的链接置成空链接,我们一般会用两种方法: 1 <a href=" ...
- 6.9 Android 优缺点
Android N主要在运行时和图形处理上做了更新. 运行时间上,Android N对编译器进行了优化,软件的运行时间提升了3-6倍.引入了一个全新的JIT编译器,使得App安装速度快了75%,编译代 ...
- haskell中的do
在haskell中,有一个do的语句专门用来做一些不那么“干净”的事情,比如读写都需要用do来开头 一开始以为do的作用是做monad,后来发现是错误的,其实do做的事情是包裹一个顺序操作 比如在如下 ...
- How to Read a Book
主题: 讲述阅读的四种层次,以及每种层次所需要的.截然不同的阅读方法. 主要声明与论点: 带着问题阅读,时刻不忘在书中寻找问题的答案: 高速阅读,以最短的时间了解一本书的全貌,然后决定是否值得再次阅读 ...
- Dynamic CRM 2013学习笔记(六)备份和恢复
这节我们将讨论下怎么维护CRM,包括以下主要内容: 备份CRM DB 备份CRM 系统 恢复CRM DB 恢复 CRM 系统 一. 备份CRM DB 下面的步骤将为CRM DB创建一个维护计划 ...
- Session为null无法访问
我们在一般处理程序中需要访问Session为null 无法访问和操作 处理方案: 1.导入命名空间 System.Web.SessionState 2.实现IRequiresSessionState ...
- C++中虚析构函数作用
我们知道,用C++开发的时候,用来做基类的类的析构函数一般都是虚函数.可是,为什么要这样做呢?下面用一个小例子来说明: 有下面的两个类: class ClxBase{public: ...
- [MFC] 向文本编辑框写入数据与从其中读取数据
GetDlgItemText(IDC_USER_NAME_EDIT,m_csUserName); SetDlgItemText(IDC_USER_NAME_EDIT,s);
- Qt 5.3.1 版本应用程序的发布问题
问题描述:用过Qt的朋友,都知道,完成的Qt程序,只能在QT环境里运行.在debug环境里,没有配置环境路线的情况下,必须包含多个dll库,然而每个dll库的大小确实很大的.但有时候还是会失败的,在一 ...
- fir.im Weekly - 工欲善其事,必先利其器
这周为大家搜罗了一些优秀的 GitHub 资源.APP开发工具.产品UI设计资源等等,同时也有一些程序员个人成长的Tips,"软硬件兼备"也许事半功倍不只是梦! Open-Sour ...