You are given two lists of commits from different branches of a version control system. Each commit in the lists consists of a commit ID, a timestamp, and a status indicating whether the commit was successful (status 1) or unsuccessful (status 0). Your task is to merge the commits from both lists into a single list, ensuring that:
Your task is to merge the commits according to the rules above, and print the commit IDs of the merged commits in sorted order based on their timestamps.
Print the commit IDs of merged commits one per line, in sorted order based on timestamp.
Input
3
b8a5gt 1000 1
cd54yt 1500 1
kl35nv 1500 0
2
v4ui6b 1000 1
pw2bud 500 1
Output
pw2bud
b8a5gt
v4ui6b
cd54yt
Explanation In the lists provided above, we observe one failed commit with ID kl35nv. This commit is not considered in the final list of commits. The remaining commits are sorted based on their timestamps: pw2bud (500) comes before b8a5gt and v4ui6b (1000), and both b8a5gt and v4ui6b precede cd54yt (1500). Between b8a5gt and v4ui6b, although they share similar timestamps, b8a5gt originates from the first list, so it is placed before v4ui6b. Hence, the final list is pw2bud -> b8a5gt -> v4ui6b -> cd54yt.
Input
4
rw1ts6 900 1
cc9n7r 1200 1
kp0zw3 700 0
y5bnm8 2000 1
4
rzq3dx 700 1
u521nc 1200 0
b8po89 4000 1
rw6cvz 800 1
Output
rzq3dx
rw6cvz
rw1ts6
cc9n7r
y5bnm8
b8po89
Explanation In the lists provided above, we observe failed commits with ID kp0zw3 and u521nc. These commits will not be considered in the final list of commits. The remaining commits are sorted based on their timestamps: rzq3dx (700) < rw6cvz (800) < rw1ts6 (900) < cc9n7r (1200) < y5bnm8 (2000) < b8po89 (4000). Between cc9n7r and u521nc, although they share similar timestamps, cc9n7r originates from the first list, so it is placed before u521nc but u521nc is not considered because it is a failed commit. Hence, the final list is rzq3dx -> rw6cvz -> rw1ts6 -> cc9n7r -> y5bnm8 -> b8po89.

Adobe Hackthon 2026 Discussion • Pending