Problem:


Score : 200 points

Problem Statement

You have decided to write a book introducing good restaurants.
There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i.
No two restaurants have the same score.

You want to introduce the restaurants in the following order:

The restaurants are arranged in lexicographical order of the names of their cities.

If there are multiple restaurants in the same city, they are arranged in descending order of score.

Print the identification numbers of the restaurants in the order they are introduced in the book.

Constraints

1 ≤ N ≤ 100

S is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.

0 ≤ P_i ≤ 100

P_i is an integer.

P_i ≠ P_j (1 ≤ i < j ≤ N)

Input

Input is given from Standard Input in the following format:

N
S_1 P_1
:
S_N P_N

Output

Print N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.

Sample Input 1

6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40

Sample Output 1

3
4
6
1
5
2

The lexicographical order of the names of the three cities is kazan < khabarovsk < moscow. For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,2.

Sample Input 2

10
yakutsk 10
yakutsk 20
yakutsk 30
yakutsk 40
yakutsk 50
yakutsk 60
yakutsk 70
yakutsk 80
yakutsk 90
yakutsk 100

Sample Output 2

10
9
8
7
6
5
4
3
2
1



Sample input:
6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40


Sample output:
3
4
6
1
5
2

Submission status: Accepted

Solution code:
n = int(input())

x = []

for i in range(n) :
    s, p = map(str, input().split())
    x.append((s, -int(p), i+1))

x.sort()

for i in range(n) :
    print(x[i][2])

Submission status: Accepted

Solution code:
N = int(input())
x = []
for i in range(N):
    S,P = input().split()
    P=int(P)
    x.append((S,-P,i+1))
x.sort()
for i in range(N):
    print(x[i][2])

Submission status: Accepted

Solution code:
N=int(input())
S=[]
for i in range(N):
    S.append(list(input().split()))
    S[i][1]=-int(S[i][1])
for i in range(N):
    print(sorted(range(N),key=lambda k : S[k])[i]+1)

Submission status: Accepted

Solution code:
from operator import itemgetter

N = int(input())
X=[]
S=[]
P=[]

for n in range(N):
    X.append([n+1])

for n in range(N):
    s, p = map(str, input().split())
    S.append(s)
    P.append(int(p))

for n, m in enumerate(S):
    X[n].append(m)

for n, m in enumerate(P):
    X[n].append(m)

X.sort(key=lambda x:(x[1], -x[2]))

for n in range(N):
    print(X[n][0])

Submission status: Accepted

Solution code:
N = int(input())
r = []
for i in range(1,N+1):
    s, p = input().split()
    r.append((i,s,int(p)))
r.sort(key = lambda x: "{}{:03}".format(x[1],100-x[2]))
for i in r:
    print(i[0])

Submission status: Accepted

Solution code:
N = int(input())
lst = []
for i in range(N):
	a, b = map(str, input().split())
	lst.append([a, int(b), i+1])

lst.sort(key = lambda x : x[1], reverse = True)
lst.sort(key = lambda x : x[0])

for i in range(N):
	print(lst[i][2])

Submission status: Accepted

Solution code:
N=int(input())
sp=[]
for i in range(N):
  s,p=input().split()
  sp.append([s,int(p),i+1])
sp.sort(key=lambda sp:(sp[0],-sp[1]))
for i in sp:print(i[2])

Submission status: Accepted

Solution code:
List=[]
n=int(input())
for i in range(n):
    a,b=input().split()
    List.append([a,int(b),i+1])
List=sorted(List, key=lambda x:(x[0],-x[1]))
for i in range(n):
    print(List[i][2])

Submission status: Accepted

Solution code:

        
N=int(input())
sp=[]
for i in range(1,N+1):
    s,p=input().split()
    sp.append([s,int(p),i])
    

sp.sort(reverse=False)

x=100
for i in sp:
    i.insert(1,x)
    x-=1
    

sp.sort(reverse=False)

for i in sp:
    print(i[3])

Submission status: Accepted

Solution code:
n = int(input())
R = [list(input().split()) for i in range(n)]

for i in range(n):
    R[i].append(i+1)

R = sorted(R, key=lambda x: int(x[1]), reverse=True)
R = sorted(R, key=lambda x: x[0])

for r in R:
    print(r[2])

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
SP = [(x.split()[0].decode('utf-8'),int(x.split()[1])) for x in readlines()]

SP = sorted((name,-pt,i+1) for i,(name,pt) in enumerate(SP))

answer = '\n'.join(str(x[2]) for x in SP)
print(answer)

Submission status: Accepted

Solution code:
n = int(input())
list = []

for i in range(n):
    s, p = map(str, input().split())
    list.append([s, int(p), i+1])

list.sort(key=lambda x:x[1], reverse=True)
list.sort(key=lambda x:x[0])
for val in list:
    print(val[2])

Submission status: Accepted

Solution code:
n=int(input())
x=[]
for i in range(n):
  a,b = input().split()
  b = int(b)
  x.append([a,-b,i+1])
x.sort()
for t in x:
            print(t[2])

Submission status: Accepted

Solution code:
N = int(input())
L = []

for l in range(0,N):
	L.append(input().split())
	L[l][1] = (abs(int(L[l][1])-10**10),l+1)

L = sorted(L)

for i in range(N):
	print(L[i][1][1])

Submission status: Accepted

Solution code:
N = int(input())
restran = [list(input().split()) for i in range(N)]

for i, j in enumerate(restran):
    restran[i][1] = int(restran[i][1])
    restran[i].append(i+1)

restran = sorted(restran, reverse=True, key=lambda restran: restran[1])
restran = sorted(restran, key=lambda restran: restran[0])

for i in range(len(restran)):
    print(restran[i][2])

Submission status: Accepted

Solution code:
from operator import itemgetter

n = int(input())
s = []; p = []; c = []
for i in range(n):
    s0, p0 = input().split()
    c.append(i); s.append(s0); p.append(int(p0))

ans = list(zip(s, p, c))
ans.sort(key=itemgetter(1), reverse=True)
ans.sort(key=itemgetter(0))

# print(ans)
for i in range(n):
    print(ans[i][2]+1)

Submission status: Accepted

Solution code:
n = int(input())
 
 
x = [list(input().split(" ")) for i in range(n)]
 
for i in range(n):
    x[i][1] = int(x[i][1])
 
test2 = sorted(x, key = lambda k:(k[0],-k[1]))
 
for i in range(n):
    print(x.index(test2[i]) + 1)

Submission status: Accepted

Solution code:
n=int(input())
L=[]
for i in range(n):
      a,b=input().split()
      L.append((i,a,int(b)))
L.sort(key=lambda x:x[2],reverse=True)
L.sort(key=lambda x:x[1])

for i in range(n):
      print(L[i][0]+1)

Submission status: Accepted

Solution code:
n = int(input())
data = []
for i in range(n):
    k = [i + 1] + list(input().split())
    data.append(k)
data = sorted(data, key = lambda x: (x[1], -int(x[2])))
for i in range(n):
    print(data[i][0])

Submission status: Accepted

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())

li = [list(stdin.readline().rstrip().split()) for _ in range(n)]

for i in range(len(li)):
    li[i][1] = int(li[i][1])

li2 = sorted(li,key=lambda x:(x[0],x[1]*(-1)))

for s in range(len(li)):
    print(li.index(li2[s])+1)

Submission status: Accepted

Solution code:
n = int(input())
sp = []
for i in range(n):
    s,p = input().split()
    sp.append([s,int(p),i+1])
sp.sort(key = lambda sp:(sp[0],-sp[1]))
for i in sp:print(i[2])

Submission status: Accepted

Solution code:
n = int(input())
g = []
for i in range(n):
    s, p = input().split()
    p = int(p)
    g.append([i+1, s, p])
g.sort(key=lambda x: (x[1], -x[2]))
for v in g:
    print(v[0])

Submission status: Accepted

Solution code:
# 行数
N = int(input().strip())

# 2次元配列
l = []
for i in range(N):
    array = list(input().split())
    array[1]=int(array[1])
    array.append(i+1)
    l.append(array)

l.sort(key=lambda x: x[1], reverse=True)
l.sort(key=lambda x: x[0])

for i in range(N):
    print(l[i][2])

Submission status: Accepted

Solution code:
N = int(input())
dic = {}
for i in range(N):
    sp = input().split()
    s = sp[0]
    p = int(sp[1])
    if s in dic:
        dic[s].append([p,i])
    else:
        dic[s] = [[p,i]]
for key in sorted(dic):
  for j in sorted(dic[key], reverse = True):
    print(j[1]+1)

Submission status: Accepted

Solution code:
n=int(input())
L=[]
for i in range(1,n+1):
      a,b=input().split()
      L.append((i,a,int(b)))
      
L.sort(key=lambda x:x[2],reverse=True)
L.sort(key=lambda x:x[1])

for i in range(n):
      print(L[i][0])

Submission status: Accepted

Solution code:
n = int(input())
li = [input().split() for _ in range(n)]
#print(src)
#[['khabarovsk', '20'], ['moscow', '10'], ['kazan', '50'], ['kazan', '35'], ['moscow', '60'], ['khabarovsk', '40']]
key_li = []
for l in li:
    if l[0] not in key_li:
        key_li.append(l[0])
dict = {}
sorted_ki = sorted(key_li)
for i,s in enumerate(sorted_ki):
    dict[i] = []
    for j,l in enumerate(li):
        if s == l[0]:
            dict[i].append([int(l[1]),j])
fin_li = []
for k in range(len(dict)):
    each_li = []
    for d in dict[k]:
        if d not in each_li:
            each_li.append(d[0])
    s_e_li = sorted(each_li, reverse=True)
    for s_e in s_e_li:
        for d in dict[k]:
            if s_e == d[0]:
                fin_li.append(d[1]+1)
for f in fin_li:
    print(f)

Submission status: Accepted

Solution code:
n = int(input())
l = []
l1 = [0]
for i in range(n):
    l1 = input().split()
    l.append([l1[0],int(l1[1]),i+1])
l_rank = sorted(sorted(l, key=lambda x: x[1], reverse=True),key=lambda x: x[0])
for i in range(n):
    print(l_rank[i][2])

Submission status: Accepted

Solution code:
n = int(input())
line = [[] for i in range(n)]
for i in range(n):
    inputlist = input().split()
    line[i].append(inputlist[0])
    line[i].append(int(inputlist[1]))
    line[i].append(i+1)
line.sort(key=lambda x:(x[0],-x[1]))
for i in range(n):
    print(line[i][2])

Submission status: Accepted

Solution code:
n = int(input())


x = [list(input().split(" ")) for i in range(n)]

for i in range(n):
    x[i][1] = int(x[i][1])

test2 = sorted(x, key = lambda k:(k[0],-k[1]))

for i in range(n):
    print(x.index(test2[i]) + 1)

Submission status: Accepted

Solution code:
from sys import stdin
from operator import itemgetter

def list_align(l):
    try :
        return int(l) * -1
    except:
        return l

n = int(stdin.readline().rstrip())
shops = [list(map(lambda x:list_align(x), stdin.readline().rstrip().split())) + [i+1] for i in range(n)]
shops.sort()
for i in range(n):
    print(shops[i][2])

Submission status: Accepted

Solution code:
N = int(input())
tmp = list()
for i in range(N):
    s,p = input().split()
    tmp.append([s,int(p),i+1])
tmp = sorted(tmp, key = lambda x:x[1], reverse = 1)
tmp = sorted(tmp, key = lambda x:x[0])
tmp = [x[2] for x in tmp]
for i in range(N):
    print(tmp[i])

Submission status: Accepted

Solution code:
from operator import itemgetter

N = int(input())
S = []
P = []
idx = []
for i in range(N):
    s,p = input().split()
    p = int(p)
    S.append(s)
    P.append(p)
    idx.append(i)

A = zip(idx,S,P)
A = sorted(A, key=itemgetter(2),reverse=True)
A = sorted(A, key=itemgetter(1))

idx, S, P = zip(*A)

for i in range(N):
    print(idx[i]+1)

Submission status: Accepted

Solution code:
n = int(input())
L = [list(input().split()) for _ in range(n)]
L2 = sorted(L)
L3 = [i[0] for i in L2]
L4 = list(set(L3))
L4.sort()
L5 = []
L6 = []
for k in L4:
  s = []
  for v in L2:
    if v[0]==k:
      s.append(int(v[1]))
  s = sorted(s, key=int, reverse=True)
  for t in s:
    L5.append(str(t))
for i in range(n):
  L6.append([L3[i],L5[i]])
for u in L6:
  print(L.index(u)+1)

Submission status: Accepted

Solution code:
n=int(input())
sp_lis=[]
for i in range(n):
    s,p=input().split()
    sp_lis.append([s,100-int(p),i+1])
sp_lis.sort()
for j in range(n):
    print(sp_lis[j][2])

Submission status: Accepted

Solution code:
N = int(input())

l = []
for i in range(N):
    s, p = input().split()
    l.append([s, int(p), i+1])

l = sorted(l, key=lambda x: x[1], reverse = True)
l = sorted(l, key=lambda x: x[0])

for j in range(N):
    print(l[j][2])

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
sp = [ list(input().split()) for _ in range(n) ]
for i in range(n):
    sp[i][1] = int(sp[i][1])
    sp[i].append(i+1)
# print(sp)

sp.sort(key=lambda x:x[1],reverse=True)
# print(sp)

sp.sort(key=lambda x:x[0])
# print(sp)

for i in range(n):
    print(sp[i][2])

Submission status: Accepted

Solution code:

N = int(input())
book = []
for i in range(N):
    s , p = input().split()
    book.append([s,int(p),i + 1])
if N == 1:
    print(1)
    exit()
book.sort()
tmp_name = book[0][0]
tmp_list = []
tmp_list.append(book[0])

for i in range(1,N):
    if book[i][0] == tmp_name:
        tmp_list.append(book[i])
    else:
        tmp_list.sort(key = lambda x: -x[1])
        for j in tmp_list:
            print(j[2])
        tmp_name = book[i][0]
        tmp_list = []
        tmp_list.append(book[i])
    if i == N - 1:
        tmp_list.sort(key=lambda x: -x[1])
        for j in tmp_list:
            print(j[2])

Submission status: Accepted

Solution code:
n = int(input())
rest = []
for i in range(n):
  s_, p_ = input().split()
  p_ = int(p_)
  rest.append([s_, p_, i+1])

rest.sort(key=lambda x:x[1], reverse=True)
rest.sort(key=lambda x:x[0])

for i in range(n):
  print(rest[i][2])

Submission status: Accepted

Solution code:
n=int(input())

lista=[]

for i in range(n): 
	s,p = map(str,input().split())
	p=int(p)
	lista.append([s,p,i+1])
	
	
#print(lista)
	
lista.sort(key=lambda x:-x[1])
#print(lista)

lista.sort(key=lambda x:x[0])
#print(lista)

ans=0
list_ans=[]
for i in range(n):
	ans=lista[i][2]
	list_ans.append(ans)

for i in range(n):
	print(list_ans[i])

Submission status: Accepted

Solution code:
n=int(input())
a = []
for _ in range(n):
    a.append(input().split())
for i in sorted(range(n), key=lambda i:(a[i][0], -int(a[i][1]))):
    print(i + 1)

Submission status: Accepted

Solution code:
n=int(input())
rest=[[0]*3]*n
for i in range(n):
    s,p=input().split()
    rest[i]=s,int(p),i+1
rest.sort(key=lambda l:(l[0],-l[1]))
for i in range(n): print(rest[i][2])

Submission status: Accepted

Solution code:
N=int(input())
V=[]
for i in range(N):
    a,b=map(str,input().split())
    U=[a,-int(b),i]
    V.append(U)

V.sort()
for _,_, i in V:
    print(i+1)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    s = [
        [-int(i) if i.isdigit() else i for i in input().split()] + [j]
        for j in range(1, n + 1)
    ]
    for _, _, i in sorted(s):
        print(i)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N=int(input())
A=[]

for i in range(N):
    s,p=map(str,input().split())
    p=-1*int(p)
    A.append([s,p,i+1])

A.sort()

for i in range(N):
    print(A[i][2])

Submission status: Accepted

Solution code:
n = int(input())
a = []
for i in range(n):
  s,p = map(str, input().split())
  a.append([s,int(p),i+1])
  a.sort(key=lambda x:x[1],reverse =True)
  a.sort(key =lambda x:x[0])
for e in a:
  print(e[2])

Submission status: Accepted

Solution code:
n = int(input())
S = [input().split()+[i+1] for i in range(n)]
t = sorted(S, key=lambda x: [x[0], -int(x[1])])
for m in t:
    print(m[2])

Submission status: Accepted

Solution code:
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N = int(input())
    RVS = [input().rstrip().split(' ')+[i+1] for i in range(N)]
    RVS = [(x[0],int(x[1]),x[2]) for x in RVS]
    RVS.sort(key=itemgetter(1), reverse=True)
    RVS.sort(key=itemgetter(0))
    for x in RVS:
        print(x[2])

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
sp=[]
for i in range(n):
  s=input().split()
  t=[s[0],int(s[1]),i+1]
  sp.append(t)
from operator import itemgetter
sp.sort(key=itemgetter(1),reverse=1)
sp.sort(key=itemgetter(0))
for i in range(n):
  print(sp[i][2])

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40"""
        output = """3
4
6
1
5
2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """10
yakutsk 10
yakutsk 20
yakutsk 30
yakutsk 40
yakutsk 50
yakutsk 60
yakutsk 70
yakutsk 80
yakutsk 90
yakutsk 100"""
        output = """10
9
8
7
6
5
4
3
2
1"""
        self.assertIO(input, output)
def resolve():
    n=int(input())
    towns=[]
    for i in range(n):
        x=input().split()
        towns.append([x[0],-int(x[1]),i+1])
    towns.sort()
    for i in towns:
        print(i[2])

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
N=int(input())
L=[]
for i in range(N):
    a,b=input().split()
    L.append((a,int(b),i+1))
L.sort(key=lambda x:x[1],reverse=True)
L.sort(key=lambda x:x[0])
for i in range(N):
    print(L[i][2])

Submission status: Accepted

Solution code:
N = int(input())
S = []
for i in range(N):
  S_tmp, P_tmp = input().split()
  P_reverse = chr(100 - int(P_tmp))
  S.append(S_tmp + str(P_reverse) + '_' + str(i+1))
for i in range(N):
  S_sort = sorted(S)
  print(S_sort[i].split('_')[-1])

Submission status: Accepted

Solution code:
N = int(input())
S = [input().split() + [i+1] for i in range(N)]
S_new = sorted(S, key=lambda x: (x[0], -int(x[1])))
for i in range(N):
    print(S_new[i][2])

Submission status: Accepted

Solution code:
N = int(input())
SP = []
for i in range(N):
    S,P = input().split()
    SP.append([S,100-int(P),i+1])
SP.sort()
for j in range(N):
    print(SP[j][2])

Submission status: Accepted

Solution code:
n = int(input())

arr = []
for i in range(1, n+1):
    s, p = input().split()
    arr.append([i, s, int(p)])

arr.sort(key=lambda x: [x[1], -x[2]])

for item in arr:
    print(item[0])

Submission status: Accepted

Solution code:
n = int(input())
s = {i+1: tuple(input().split()) for i in range(n)}
for k, v in sorted(s.items(), key=lambda x: (x[1][0], -int(x[1][1]))):
    print(k)

Submission status: Accepted

Solution code:
dic={}
N = int(input())
for i in range(N):
  inp = input().split()
  S = inp[0]
  P = int(inp[1])
  if S in dic:
    dic[S].append([P,i])
  else:
    dic[S] = [[P,i]]

for key in sorted(dic):
    for j in sorted(dic[key], reverse=True):
        print(j[1]+1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

n = input()

l = []

for i in range(n):
    inpt = raw_input().split()
    l.append((inpt[0], int(inpt[1]), i + 1))

l.sort(key=lambda x:(x[0], -x[1]))

for i in l:
    print (i[2])

Submission status: Accepted

Solution code:
from operator import itemgetter

n = int(input())
p = [input().split() for l in range(n)]
for i in range(0,n):
    p[i].insert(0,i+1)
    p[i][2] = int(p[i][2])

p.sort(key=itemgetter(2),reverse=True)
p.sort(key=itemgetter(1))
for i in range(0,n):
    print(p[i][0])

Submission status: Accepted

Solution code:
n =int(input())
book = []
for i in range(1,n+1):
      s,p = input().split()
      p = int(p)
      book.append((i,s,p))

book.sort(key=lambda x:x[2],reverse=True)
book.sort(key=lambda x:x[1])

for i in range(n):
      print(book[i][0])

Submission status: Accepted

Solution code:
N=int(input())
sp=[]
for _ in range(N):
    sp.append([i for i in input().split()])

for i in range(N):
    sp[i][1]=-int(sp[i][1])

sp2=sorted(sp)

for i in range(N):
    s=sp2[i]
    print(sp.index(s)+1)

Submission status: Accepted

Solution code:
from collections import defaultdict
import heapq
import sys
input = sys.stdin.readline
 
 
def main():
    N = int(input())

    D = []
    d = defaultdict(list)
    for i in range(1, N+1):
        s, p = input().split()
        D.append([s, int(p)*(-1), i])
    D.sort()

    for d in D:
        print(d[2])
        
 
 
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
li = []#[都市名,点数,番号]
for i in range(n):
  li_1 = input().split()
  li_1[1] = int(li_1[1])
  li_1.append(i+1)
  li.append(li_1)
li = sorted(li, key=lambda x: x[0])
new_li = []
new_li_2 = []
a = li[0][0]
for i in range(n):
  if a == li[i][0]:
    new_li_2.append(li[i])
    if i == n-1:
      new_li.append(new_li_2)
  else:
    new_li.append(new_li_2)
    new_li_2 = []
    a = li[i][0]
    new_li_2.append(li[i])
    if i == n-1:
      new_li.append(new_li_2)
#print(new_li)
for i in range(len(new_li)):
  new_li[i] = sorted(new_li[i], key=lambda x: x[1])
  new_li[i].reverse()
ans_li =[]
for i in range(len(new_li)):
  for j in range(len(new_li[i])):
    ans_li += [new_li[i][j]]
for i in range(n):
  print(ans_li[i][2])

Submission status: Accepted

Solution code:
N=int(input())
L=[]
for i in range(1,N+1):
    s,p=input().split()
    p=int(p)
    L.append((i,s,p))
L.sort(key=lambda x:x[2],reverse=True)
L.sort(key=lambda x:x[1])
for l in L:
    print(l[0])

Submission status: Accepted

Solution code:
N = int(input())
names = set()
citydict = dict()
for i in range(N):
    S,P = input().split()
    names.add(S)
    if S in citydict:
        citydict[S].append((int(P),i))
    else:
        citydict[S] = [(int(P),i)]

for name in sorted(names):
    for point in sorted(citydict[name],reverse = True):
        print(point[1] + 1)

Submission status: Accepted

Solution code:
n = int(input())
citynames = set()
citydict = dict()

for i in range(n):
  s,p = input().split()
  citynames.add(s)
  if not s in citydict:
    citydict[s] = [(int(p), i)]
  else:
    citydict[s].append((int(p), i))

for name in sorted(citynames):
  for point in sorted(citydict[name], reverse=True):
    print(point[1]+1)

Submission status: Accepted

Solution code:
import collections

n = int(input())

scores = collections.defaultdict(list)

for i in range(1, n + 1):
    city, score = input().split()
    scores[city].append([i, int(score)])

# print(scores)

for city in sorted(scores):
    sorted_score = sorted(scores[city], key=lambda x: x[1], reverse=True)
    for v in sorted_score:
        print(v[0])

Submission status: Accepted

Solution code:
n= int(input())
a= []
for i in range(n):
    s,p=input().split()
    a.append([s,int(p),i+1])
tmp = sorted(a,key=lambda a: a[1], reverse=True)
a = sorted(tmp, key=lambda a: a[0])
for i in a:
    print(i[2])

Submission status: Accepted

Solution code:
N = int(input())
restaurants = [input().split() for i in range(N)]
for i, restaurant in enumerate(restaurants):
    restaurant.append(i+1)

tmp = sorted(restaurants, key=lambda x: int(x[1]), reverse=True)
sorted_rest = sorted(tmp, key=lambda x: x[0])

for elem in sorted_rest:
    print(elem[2])

Submission status: Accepted

Solution code:
N = int(input())
restaurants = [input().split() for i in range(N)]
for i, restaurant in enumerate(restaurants):
    restaurant.append(i+1)
    restaurant[1] = int(restaurant[1])


tmp = sorted(restaurants, key=lambda x: x[1], reverse=True)
sorted_rest = sorted(tmp, key=lambda x: x[0])

for elem in sorted_rest:
    print(elem[2])

Submission status: Accepted

Solution code:
from operator import itemgetter
n = int(input())

list_res = []
for i in range(n):
    a, b = map(str, input().split())
    list_res.append([a,int(b) * -1, i + 1])

list_res = sorted(list_res, key = itemgetter(0, 1))


for i in list_res:
    print(i[2])

Submission status: Accepted

Solution code:
n = int(input())
l = []
for i in range(n):
    a, p = input().split()
    l.append([a, -int(p), i + 1])
l.sort()
for j in range(n):
    print(l[j][2])

Submission status: Accepted

Solution code:
N = int(input())
SP=[]
for i in range(N):
    S, P =input().split(' ')
    SP.append([S,100-int(P),i+1])
SP.sort()

for i in range(N):
    print(SP[i][2])

Submission status: Accepted

Solution code:
N = int(input())
r = []

for i in range(N):
    city, score = input().split()
    r.append((city, int(score), i+1))

r = sorted(r, key = lambda x:(x[0], -x[1]))
for city, score, num in r:
    print(num)

Submission status: Accepted

Solution code:
n = int(input())
score = []
for i in range(n):
    s, p = list(input().split())
    tmp = [s, int(p)]
    tmp.append(i+1)
    score.append(tmp)
score.sort(key = lambda x: (x[0], -x[1]))
for i in range(n):
    print(score[i][2])

Submission status: Accepted

Solution code:
n = int(input())
score = []
for i in range(n):
    a, b = list(input().split())
    tmp = [a, int(b)]
    tmp.append(i)
    score.append(tmp)

score.sort(key=lambda x: (x[0], -x[1]))


for i in range(n):
    print(score[i][2]+1)

Submission status: Accepted

Solution code:
#input
N = int(input())
S = [""] * N
P = [0] * N

for i in range(N):
    S[i], P[i] = input().split()

#output
for i in range(N):
    P[i] = int(P[i])

num_list = [i+1 for i in range(N)]
my_list = [(i, j, k) for i, j, k in  zip(S, P, num_list)]
my_list = sorted(my_list, key = lambda x:(x[0], -x[1]))

for k in range(N):
    print(my_list[k][2])

Submission status: Accepted

Solution code:
n=int(input())
d=dict()

for i in range(n):
  s,p=input().split()
  d[s+"{0:03d}".format(100-int(p))]=i+1

d2=sorted(d.items())
for i in range(len(d2)):
  print(d2[i][1])

Submission status: Accepted

Solution code:
n = int(input())
l = []
for i in range(1, n + 1):
  c, p = input().split()
  p = int(p)
  l.append([c, p, i])
l.sort(key=lambda x:(x[0], -x[1]))
for v in l:
  print(v[2])

Submission status: Accepted

Solution code:
n = int(input())
s = []
p = []
ans = [0]*n
for i in range(n):
    s1,p1 = [str(i) for i in input().split()]
    s.append(s1)
    p.append(p1)
    ans[i] = i + 1
for i in range(n):
    p[i] = int(p[i])
flag = 1
while flag:
    flag = 0
    for i in range(n-1,0,-1):
        if s[i] < s[i-1]:
            s[i],s[i-1] = s[i-1],s[i]
            p[i],p[i-1] = p[i-1],p[i]
            ans[i],ans[i-1] = ans[i-1],ans[i]
            flag = 1
flag = 1
while flag:
    flag = 0
    for i in range(n-1):
        if s[i] == s[i+1] and p[i] < p[i+1]:
            p[i],p[i+1] = p[i+1],p[i]
            ans[i],ans[i+1] = ans[i+1],ans[i]
            flag = 1
for i in range(n):
    print(ans[i])

Submission status: Accepted

Solution code:
N = int(input())
SP = []
for i in range(N):
    S, P = map(str, input().split())
    SP.append([S, int(P), i+1])

SP.sort(key = lambda x:x[1], reverse=True)
SP.sort(key = lambda x:x[0])

for e in SP:
    print(e[2])

Submission status: Accepted

Solution code:
n = int(input())
number = [0] * n
s = [0] * n
p = [0] * n

for i in range(n):
  number[i] = i+1
  s[i], p[i] = input().split()
  p[i] = int(p[i])
  
for i in range(n):
  for j in range(1, n-i):
    if s[j-1] > s[j]:
      s[j-1], s[j] = s[j], s[j-1]
      p[j-1], p[j] = p[j], p[j-1]
      number[j-1], number[j] = number[j], number[j-1]
    elif (s[j-1] == s[j]) and (p[j-1] < p[j]):
      s[j-1], s[j] = s[j], s[j-1]
      p[j-1], p[j] = p[j], p[j-1]
      number[j-1], number[j] = number[j], number[j-1]
      
for i in range(n):
  print(number[i])

Submission status: Accepted

Solution code:
N = int(input())

S_list= [[i+1,list(map(str,input().split()))] for  i in range(N)]
# lambda を用いて、2元配列をそれぞれソート可能
S_list = sorted(S_list,key = lambda x :(x[1][0],-int(x[1][1]) ))

for i in range(N):
    print(S_list[i][0])

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

n=int(input())
l=[]
for _ in range(1,n+1):
    s,p=input().split()
    p=int(p)*-1
    t=(s,p,_)
    l.append(t)
l=sorted(tuple(l))
for i in range(n):
    print(l[i][2])

Submission status: Accepted

Solution code:
N=int(input())
L=[]
for i in range(N):
    a,p=input().split()
    L.append([a,-int(p),i])
L.sort()
for i in range(N):
    print(L[i][2]+1)

Submission status: Accepted

Solution code:
# -*-coding: utf-8 -*-
N = int(input())
sp = []
for i in range(N):
    s = list(input().split())
    s.append(i+1)
    sp.append(s)

for i in range(N):
    sp[i][1] = int(sp[i][1])

sp.sort(key=lambda x:(x[0], -x[1]))

for i in range(N):
    print(sp[i][2])

Submission status: Accepted

Solution code:
n = int(input())
sp = [[i + 1, input().split()] for i in range(n)]
sp = sorted(sp, key=lambda x: (x[1][0], -int(x[1][1])))
for k, v in sp:
    print(k)

Submission status: Accepted

Solution code:
n = int(input())
li = [[a+1, input().split()] for a in range(n)]
li = sorted(li, key=lambda x:(x[1][0],-1 * int(x[1][1])))
for l in li:
  print(l[0])

Submission status: Accepted

Solution code:
n = int(input())
r = []
for i in range(n):
  c,p = input().split()
  r.append([c,-int(p),i])
r.sort()
for j in range(n):
  print(r[j][2]+1)

Submission status: Accepted

Solution code:
N=int(input())
d=[input().split()+[i+1] for i in range(N)]
d.sort(key=lambda x:(x[0],-int(x[1])))
for i in d:
  print(i[2])

Submission status: Accepted

Solution code:
n=int(input())
d = [input().split() + [i + 1] for i in range(n)]
d.sort(key=lambda x: (x[0], -int(x[1])))
for i in d:
  print(i[2])

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import defaultdict
from operator import itemgetter
N = int(input())

A = [[] for _ in range(N)]
for i in range(N):
    S, P = [x.strip() for x in input().split()]
    A[i].append(S)
    A[i].append(int(P))

B = sorted(A, key=itemgetter(1), reverse=True)
B = sorted(B, key=itemgetter(0))

for i in B:
    for j, v in enumerate(A):
        if i[0] == v[0] and i[1] == v[1]:
            print(j + 1)
            break

Submission status: Accepted

Solution code:
N = int(input())
SP = [list(map(str,input().split())) for _ in range(N)]
for i in range(N):
    SP[i][1] = int(SP[i][1])
for i in range(N):
    SP[i].append(i+1)
SP.sort()
for i in range(N**2):
    for i in range(N-1):
        if SP[i][0] == SP[i + 1][0] and SP[i][1] < SP[i+1][1]:
            A = SP[i]
            SP[i] = SP[i + 1]
            SP[i + 1] = A
for i in range(N):
    print(SP[i][2])

Submission status: Accepted

Solution code:
N = int(input())
points = []
for i in range(N):
    points.append(input().split())
for j, point in enumerate(points):
    point.append(j+1)
points.sort(key=lambda x: int(x[1]), reverse=True)
points.sort(key=lambda x: x[0])
for p in points:
    print(p[2])

Submission status: Accepted

Solution code:
n =int(input())
sp = []
for i in range(n):
  s,p = map(str, input().split())
  sp.append([s,int(p),i+1])
sp.sort(key= lambda x:x[1] ,reverse=True)
sp.sort(key= lambda x:x[0] )

for e in sp:
  print(e[2])

Submission status: Accepted

Solution code:
n = int(input())
ans = []
for i in range(n):
    c, p = input().split()
    p = int(p)
    ans.append([c, -p, i+1])
ans.sort()
for _ in ans:
    print(_[2])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
dic = [0]*n
for i in range(n):
    s, p = input().split()
    dic[i] = (s, int(p), i+1)
dic.sort(key=lambda dic: dic[1],reverse=True)
dic.sort(key=lambda dic: dic[0])
for i in dic:
    print(i[2])