Codeforces Round 384 (Div. 2)
A
Vladik and flights
Codeforces
1200
原题
←B →
翻译中…

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.

翻译中…

Input

翻译中…

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.

翻译中…

Output

翻译中…

Print single integer — the minimum cost Vladik has to pay to get to the olympiad.

翻译中…

Note

翻译中…

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

翻译中…

In the second example Vladik can fly directly from the airport $5$ to the airport $2$, because they belong to the same company.

翻译中…

样例

Input #1
4 1 4
1010
Output #1
1
InputCopy OutputCopy
Input #2
5 5 2
10110
Output #2
0
InputCopy OutputCopy
题目信息
题号
743A
时间限制
2 s
内存限制
256 MB
标签
构造
贪心
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。