포럼
문제 ICPC00312

D. Driver Disagreement

설명

-3mm

-10mm

Alice and Bob are travelling in Italy. They are travelling by car and unfortunately they took a wrong turn. Now they are stuck in the city centre of Pisa. (You may know that you need an allowance to drive in the city centre, so they are at risk of getting a fine.) As they were not fully prepared for this, they have a map, but no GPS. The map lists all intersections. At each intersection you can go either left or right (you cannot go straight or take a U-turn, as many streets are one-way).

Of course, they paid attention when entering Pisa and tried to follow on the map. Unfortunately, Alice thinks they are at intersection \(A\), while Bob believes they are now at intersection \(B\). You can imagine this is quite a stressful situation. Instead of figuring out how to get out of Pisa, they want to know who is right first. On the map it is indicated from which intersections you can see the leaning tower of Pisa. So they believe they can conduct an experiment: drive a bit and take the same actions on the map starting from \(A\) and \(B\). They can trace the route they drive on the map for both of their starting points. As soon as the tower of Pisa should be visible for one of them but not for the other, they can look out of the window to see who is right. You may assume exactly one of them is right.

제약
입력 형식
  • The first line of the input has three space-separated integers. The first integer, \(2 \leq n \leq 10^5\) is the number of intersections. The next two integers are \(0 \leq A, B < n\), the intersections that Alice and Bob respectively think they are currently at. In particular \(A \neq B\).
  • Then follow \(n\) lines. The \(i\)'th of these lines (\(0\leq i) has three space-separated integers: \(l_i\) \(r_i\) \(t_i\). If you are at intersection \(i\) and take a left turn, you arrive at \(l_i\), while a right turn brings you to \(r_i\). The number \(t_i = 1\) if you can see the leaning tower of Pisa from intersection \(i\). Otherwise \(t_i = 0\).
출력 형식

Print the minimal number of turns it takes to show either person correct. If no experiment can tell whether Alice or Bob is correct, print "indistinguishable".

예제 1
입력
3 1 2
1 2 1
0 2 0
0 1 0
출력
indistinguishable
예제 2
입력
2 0 1
1 1 1
0 0 0
출력
0
예제 3
입력
3 1 2
1 2 0
2 0 1
0 1 1
출력
1
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC BAPC 2018

평가 및 의견

D. Driver Disagreement

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

D. Driver Disagreement

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8