CF743A.Vladik and flights

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 nn airports. All the airports are located on a straight line. Each airport has unique id from 11 to nn , Vladik's house is situated next to the airport with id aa , and the place of the olympiad is situated next to the airport with id bb . 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 aa and finish it at the airport bb .

Each airport belongs to one of two companies. The cost of flight from the airport ii to the airport jj is zero if both airports belong to the same company, and ij|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 nn , aa , and bb ( 1<=n<=1051<=n<=10^{5} , 1<=a,b<=n1<=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 nn , which consists only of characters 00 and 11 . If the ii -th character in this string is 00 , then ii -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.

输入输出样例

  • 输入#1

    4 1 4
    1010
    

    输出#1

    1
  • 输入#2

    5 5 2
    10110
    

    输出#2

    0

说明/提示

In the first example Vladik can fly to the airport 22 at first and pay 12=1|1-2|=1 (because the airports belong to different companies), and then fly from the airport 22 to the airport 44 for free (because the airports belong to the same company). So the cost of the whole flight is equal to 11 . It's impossible to get to the olympiad for free, so the answer is equal to 11 .

In the second example Vladik can fly directly from the airport 55 to the airport 22 , because they belong to the same company.

首页