아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Antennas

시간 제한4초메모리 제한2048 MB

요약
두 안테나의 거리가 두 전력 중 작은 값 이하이면 직접 통신할 수 있을 때, 안테나 a에서 b까지 최소 몇 번의 전달로 메시지를 보낼 수 있는지 구한다.
난이도

보통10점 중 5점

유형
그래프, BFS, 그리디
정답자
아직 제출이 없습니다

문제

There are nn equidistant antennas on a line, numbered from 11 to nn. Each antenna has a power rating, the power of the ii-th antenna is p_ip\_i.

The ii-th and the jj-th antenna can communicate directly if and only if their distance is at most the minimum of their powers, i.e., ∣i−j∣ ≤min⁡(p_i,p_j)|i - j| ≤ \min{(p\_i, p\_j)}. Sending a message directly between two such antennas takes 11 second.

What is the minimum amount of time necessary to send a message from antenna aa to antenna bb, possibly using other antennas as relays?

입력

Each test contains multiple test cases. The first line contains an integer tt (1≤t≤100,0001 ≤ t ≤ 100\\,000) — the number of test cases. The descriptions of the tt test cases follow.

The first line of each test case contains three integers nn, aa, bb (1≤a,b≤n≤200,0001 ≤ a, b ≤ n ≤ 200\\,000) — the number of antennas, and the origin and target antenna.

The second line contains nn integers p_1p\_1, p_2p\_2, …\dots, p_np\_n (1≤p_i≤n1 ≤ p\_i ≤ n) — the powers of the antennas. The sum of the values of nn over all test cases does not exceed 200,000200\\,000.

출력

For each test case, print the number of seconds needed to trasmit a message from aa to bb. It can be shown that under the problem constraints, it is always possible to send such a message.

예제1

  1. 예제 1

    입력
    3
    10 2 9
    4 1 1 1 5 1 1 1 1 5
    1 1 1
    1
    3 1 3
    3 3 1
    
    예상 출력
    4
    0
    2