-
Notifications
You must be signed in to change notification settings - Fork 0
/
pair_programming.py
50 lines (45 loc) · 1.19 KB
/
pair_programming.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
'''
Problem Link https://codeforces.com/problemset/problem/1547/C
'''
t = int(input())
for _ in range(t):
input()
k, n, m = map(int, input().split())
polycarp = list(map(int, input().split()))
monocarp = list(map(int, input().split()))
actions = []
a = 0
b = 0
flag1 = 0
flag2 = 0
while (a < n or b < m):
if a < n:
if (polycarp[a] == 0):
actions.append(0)
k += 1
a += 1
continue
elif (polycarp[a] <= k):
actions.append(polycarp[a])
a += 1
continue
else:
flag1 = 1
if b < m:
if (monocarp[b] == 0):
actions.append(0)
k += 1
b += 1
continue
elif (monocarp[b] <= k):
actions.append(monocarp[b])
b += 1
continue
else:
flag2 = 1
if (flag1 and flag2 or (flag2 and a >= n) or (flag1 and b >= m)):
actions = [-1]
break
else:
flag1 = flag2 = 0
print(" ".join(map(str, actions)))