-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patha291.py
More file actions
35 lines (27 loc) · 777 Bytes
/
a291.py
File metadata and controls
35 lines (27 loc) · 777 Bytes
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
import sys
data = sys.stdin.read().splitlines()
index = 0
results = []
while index < len(data):
P = data[index].strip().split()
index += 1
n = int(data[index])
index += 1
for _ in range(n):
A, B = 0, 0
ans = data[index].strip().split()
index += 1
unmatched_P = []
unmatched_ans = []
for p, a in zip(P, ans):
if p == a:
A += 1
else:
unmatched_P.append(p)
unmatched_ans.append(a)
for p in unmatched_P:
if p in unmatched_ans:
B += 1
unmatched_ans.remove(p)
results.append(f"{A}A{B}B")
sys.stdout.write("\n".join(results) + "\n")