Problem: In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.  City i is established in year Y_i and belongs to Prefecture P_i.  You can assume that there are no multiple cities that are established in the same year.  It is decided to allocate a 12-digit ID number to each city.  If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.  Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.  Find the ID numbers for all the cities.  Note that there can be a prefecture with no cities.

Submission attempts (in order):
n,m=map(int,input().split())
p=[[] for i in range(n)]
y=[]
nl=[]
for i in range(m):
    t1,t2=map(int,input().split())
    p[t1-1].append(t2)
for i in range(n):
    tl=p[i].sort()
    for j in range(len(p[i])):
        u=str(i+1)
        w=tl.index(p[i][j])
        d=str(w+1)
        while len(u)<6:
            u="0"+u
        while len(d)<6:
            d="0"+d
        t=u+d
        nl.append(t)
for i in range(m):
    print(nl[i])

n,m=map(int,input().split())
p=[[] for i in range(n)]
y=[]
nl=[]
for i in range(m):
    t1,t2=map(int,input().split())
    p[t1-1].append(t2)
for i in range(n):
    tl=sorted(p[i])
    for j in p[i]:
        u=str(i+1)
        d=str(tl.index(j)+1)
        u="0"*(6-len(u))+u
        d="0"*(6-len(d))+d
        print(u+d)

n,m=map(int,input().split())
p=[[] for i in range(n)]
y=[]
nl=[]
for i in range(m):
    t1,t2=map(int,input().split())
    p[t1-1].append(t2)
for i in range(n):
    for j in range(len(p[i])):
        u=str(i+1)
        d=str(j+1)
        while len(u)<6:
            u="0"+u
        while len(d)<6:
            d="0"+d
        t=u+d
        nl.append(t)
for i in range(m):
    print(nl[i])

n,m=map(int,input().split())
p=[[] for i in range(m)]
y=[]
nl=[]
for i in range(m):
    t1,t2=map(int,input().split())
    p[t1-1].append(t2)
for i in range(m):
    for j in range(len(p[i])):
        u=str(i+1)
        d=str(j+1)
        while len(u)<6:
            u="0"+u
        while len(d)<6:
            d="0"+d
        t=u+d
        nl.append(t)
for i in range(m):
    print(nl[i])

n,m=map(int,input().split())
p=[[] for i in range(n)]
y=[]
nl=[]
for i in range(m):
    t1,t2=map(int,input().split())
    p[t1-1].append(t2)
for i in range(n):
    tl=sorted(p[i])
    for j in p[i]:
        u=str(i+1)
        w=tl.index(j)
        d=str(w+1)
        while len(u)<6:
            u="0"+u
        while len(d)<6:
            d="0"+d
        t=u+d
        nl.append(t)
for i in range(m):
    print(nl[i])

n,m=map(int,input().split())
p=[[] for i in range(n)]
y=[]
nl=[]
for i in range(m):
    t1,t2=map(int,input().split())
    p[t1-1].append(t2)
for i in range(n):
    tl=sorted(p[i])
    for j in p[i]:
        u=str(i+1)
        w=tl.index(j)
        d=str(w+1)
        while len(u)<6:
            u="0"+u
        while len(d)<6:
            d="0"+d
        t=u+d
        nl.append(t)
for i in range(m):
    print(nl[i])

n,m=map(int,input().split())
p=[]
for i in range(m):
    t1,t2=map(int,input().split())
    p.append([i,t1,t2])
p.sort(key=lambda x:x[2])
c=[1 for i in range(n+1)]
num=[]
for i,pre,yea in p:
    tmp=str(pre).zfill(6)+str(c[pre]).zfill(6)
    num.append([i,tmp])
    c[pre]+=1
num.sort()
for i in num:
    print(i[1])

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Accepted