Skip to content

Commit 4cfcb8e

Browse files
Add files via upload
1 parent f6488b6 commit 4cfcb8e

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
for _ in range(int(input())):
2+
n = int(input())
3+
s1 = set(map(int, input().split()))
4+
s2 = set(map(int, input().split()))
5+
6+
l1 = len(s1)
7+
l2 = len(s2)
8+
9+
if l1 > l2: # l1 <= l2
10+
l1, l2 = l2, l1
11+
12+
if l1 > 1 and l2 > 1:
13+
print("YES")
14+
elif l1 == 1:
15+
if l2 > 2:
16+
print("YES")
17+
else:
18+
print("NO")
19+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
for _ in range(int(input())):
2+
3+
n, k = map(int, input().split())
4+
arr = list(map(int, input().split()))
5+
6+
extra = n - k
7+
8+
ans = 0
9+
if extra == 0:
10+
for i in range(1, n, 2):
11+
if arr[i] != i//2 + 1:
12+
ans = i//2 + 1
13+
break
14+
else:
15+
ans = n//2 + 1
16+
else:
17+
for i in range(1, extra+2):
18+
if arr[i] != 1:
19+
ans = 1
20+
break
21+
else:
22+
ans = 2
23+
print(ans)

0 commit comments

Comments
 (0)