303852: CF743A. Vladik and flights
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Vladik and flights
题意翻译
###### 题目描述 $Vladik$是一位非常有竞争力的$\text{OIer}$。今年他将赢得国际奥林匹克信息学竞赛的冠军~~(AKIOI)~~。但$Vladik$现在面临的问题是找到一种最便宜的方式到达$\text{IOI}$的赛场。 $Vladik$知道有$n$个机场。所有机场都在一条直线上。机场编号为1到$n$。$Vladik$的房子位于机场$a$旁边,$\text{IOI}$赛场的地方位于机场$b$旁边。$Vladik$的房子和$\text{IOI}$赛场**可能**就在同一个机场旁边。 为了到达$\text{IOI}$赛场,$Vladik$可以乘坐任何两个机场之间的航班。但他必须在机场$a$开始,并在机场$b$结束。 每个机场属于两家公司之一。从机场$i$到机场$j$的费用为:如果两个机场属于同一家公司,则费用为0。如果两个机场属于不同的公司,则费用为$\big|i-j\big|$。 输出$Vladik$到达$\text{IOI}$赛场的最小费用题目描述
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<=10^{5} $ , $ 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.
输入输出样例
输入样例 #1
4 1 4
1010
输出样例 #1
1
输入样例 #2
5 5 2
10110
输出样例 #2
0