スパークリング黒ココア/ABC294 C - Merge Sequences

Created Sun, 19 Mar 2023 Modified Tue, 26 Sep 2023 09:13:30 +0000
  • AとBを混ぜてCにして、index拾っていく作業
  • やってることとしては #座標圧縮 のイメージ
from collections import defaultdict  
  
N, M = map(int, input().split())  
A_L = list(map(int, input().split()))  
B_L = list(map(int, input().split()))  
  
C_L = A_L + B_L  
C_L.sort()  
ans_A_L = []  
ans_B_L = []  
index_d = defaultdict(int)  
for i, c in enumerate(C_L, 1):  
    index_d[c] = i  
  
for a in A_L:  
    ans_A_L.append(index_d[a])  
for b in B_L:  
    ans_B_L.append(index_d[b])  
print(*ans_A_L)  
print(*ans_B_L)