Created
September 4, 2024 17:31
-
-
Save AashishNandakumar/c1aafbb8d8295a6707ee11c4f6351d65 to your computer and use it in GitHub Desktop.
September 4th 2024 Questions
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
# input | |
n, s = map(int, input().split()) | |
a = [0] + list(map(int, input().split())) + [0] | |
b = [0] + list(map(int, input().split())) + [0] | |
# logic | |
reachable = False | |
for i in range(1, n + 1): | |
if i == 1 and a[i] == 0: | |
print("NO") | |
break | |
if i == s and a[i] == 1: | |
print("YES") | |
break | |
if i == s and b[i] == 1: | |
reachable = True | |
elif i == s and b[i] != 1: | |
print("NO") | |
break | |
if reachable and a[i] == 1 and b[i] == 1: | |
print("YES") | |
break | |
else: | |
print("NO") |
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
# input | |
n, s = map(int, input().split()) | |
a = [0] + list(map(int, input().split())) + [0] | |
b = [0] + list(map(int, input().split())) + [0] | |
# logic | |
if a[1] == 0: | |
print("NO") | |
elif a[s] == 1 or (b[s] == 1 and any(a[i] == 1 and b[i] == 1 for i in range(s, n + 1))): | |
print("YES") | |
else: | |
print("NO") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment