Last active
November 17, 2019 08:16
-
-
Save rgab1508/cad71672089d7ed223e04bf987f178dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nTst = int(input()) | |
for i in range(nTst): | |
for i in range(nTest): | |
n = int(input()) | |
arr = input().split(" ") | |
arr = list(map(int, arr)) | |
se = input() | |
start, end = int(se.split(" ")[0]), int(se.split(" ")[1]) | |
val = start | |
for i in range(n-1): | |
#val = start | |
start = arr[val-1] | |
val = start | |
if start == end: | |
print("Yes") | |
else: | |
print("No") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment