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 水题的更多相关文章

  1. Codeforces Round #384 (Div. 2) C. Vladik and fractions 构造题

    C. Vladik and fractions 题目链接 http://codeforces.com/contest/743/problem/C 题面 Vladik and Chloe decided ...

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

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

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

  5. Codeforces Round #373 (Div. 2) B. Anatoly and Cockroaches 水题

    B. Anatoly and Cockroaches 题目连接: http://codeforces.com/contest/719/problem/B Description Anatoly liv ...

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

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

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

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

随机推荐

  1. POJ 3468 A Simple Problem with Integers (线段树)

    题意:给定两种操作,一种是区间都加上一个数,另一个查询区间和. 析:水题,线段树. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024 ...

  2. HTTP协议状态码详解(HTTP Status Code)

    转自:http://www.cnblogs.com/shanyou/archive/2012/05/06/2486134.html 使用ASP.NET/PHP/JSP 或者javascript都会用到 ...

  3. 调研一类软件的发展演变—聊天软件( 1000-2000 words, in Chinese)

    因为本人平时对聊天软件的涉及比周边其他同学而言所涉及的是比较多的.所以说想写写这个东西.(ps本文里面的具体通讯信息的时间安排不分先后) 也许最起初的通讯信息的传达是利用.烽火狼烟这一类可以远距离视觉 ...

  4. 小觑数据库(SqlServer)查询语句执行过程

    近年来,越来越多的NoSql产品不断的以技术革命的者的身份跳出来:“你看哥是多么的快,你们关型型数据库真是战五渣阿”.是的,高性能的场景下NoSql真的很出彩.而我们关系型数据库只能在墙角哭泣&quo ...

  5. Fragment之间的通信

    在本节中,你会学到 1.定义接口 2.实现接口 3.将消息传递给fragment 为了重用Fragment UI 组件,在设计中你应该通过定义每一个fragemnt自己的layout和行为,让frag ...

  6. [WinAPI] API 10 [创建、打开、读写文件,获取文件大小]

    在Windows系统中,创建和打开文件都是使用API函数CreateFile,CreateFile通过指定不同的参数来表示是新建一个文件,打开已经存在的文件,还是重新建立文件等.读写文件最为直接的方式 ...

  7. 使用Lucene.NET实现数据检索功能

    引言     在软件系统中查询数据是再平常不过的事情了,那当数据量非常大,数据存储的媒介不是数据库,或者检索方式要求更为灵活的时候,我们该如何实现数据的检索呢?为数据建立索引吧,利用索引技术可以更灵活 ...

  8. paip.gui控件form窗体的原理实现以及easyui的新建以及编辑实现

    paip.gui控件form窗体的原理实现以及easyui的新建以及编辑实现 //////新建 与编辑  var  EditForm=new Form_easyui();    if(row)     ...

  9. D. Book of Evil

    D. Book of Evil time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  10. JS 基本数据类型

    一.undefined 类型 (ECMAScript 3引入undefined类型) 1.它的值只有一个 undefined 2.未初始化的变量 会隐式转换为undeFined类型 var box; ...