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())
SP = []
for i in range(1, N+1):
    s, p = input().split()
    SP.append((s, -int(p), i))
SP.sort()
for _, _, i in SP:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
restaurants = list()
for i in range(1, N+1) :
    s, p = input().split()
    r = { 'i' : i, 's' : s, 'p' : int(p) }
    restaurants.append(r)

restaurants.sort(key=lambda r : (r['s'], -r['p']))

for r in restaurants :
    print(r['i'])

Submission status: Accepted

Solution code:
n = int(input())
S = []
count = [0] * n
for i in range(n):
    a, b = input().split()
    S.append([a, -int(b), i + 1])

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

X.sort()
for S, P, i in X:
    print(i)

Submission status: Accepted

Solution code:
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

# import math
# import string
# import fractions
# from fractions import Fraction
# from fractions import gcd
# def lcm(n,m):
#     return int(n*m/gcd(n,m))

# import re
# import array
# import copy
# import functools
# import operator

# import collections
# import itertools
# import bisect
# import heapq


# from heapq import heappush
# from heapq import heappop
# from queue import PriorityQueue as pq

# # from itertools import accumulate
# # from collections import deque
# import random


def main():
    n = int(input())
    # l=[["",0,0] for i in range(n)]
    l=[]
    # eprint(l)
    for i in range(n):
        s,m=input().split()
        m = -int(m)
        l.append([s,m,i+1])
        # l[i][0]=s
        # l[i][1]=m
        # l[i][2]=i+1
    # eprint(l)
    l.sort()
    # eprint(l)
    for x in l:
        print(x[2])

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

# import math
# import string
# import fractions
# from fractions import Fraction
# from fractions import gcd
# def lcm(n,m):
#     return int(n*m/gcd(n,m))

# import re
# import array
# import copy
# import functools
# import operator

# import collections
# import itertools
# import bisect
# import heapq


# from heapq import heappush
# from heapq import heappop
# from queue import PriorityQueue as pq

# # from itertools import accumulate
# # from collections import deque
# import random


def main():
    n = int(input())
    l=[["",0,0] for i in range(n)]
    # eprint(l)
    for i in range(n):
        s,m=input().split()
        m=-int(m)
        l[i][0]=s
        l[i][1]=m
        l[i][2]=i+1
    # eprint(l)
    l.sort()
    # eprint(l)
    for x in l:
        print(x[2])

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
def lcm(n,m):
    return int(n*m/gcd(n,m))

import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop
from queue import PriorityQueue as pq

# from itertools import accumulate
# from collections import deque
import random


def main():
    n = int(input())
    l=[["",0,0] for i in range(n)]
    # eprint(l)
    for i in range(n):
        s,m=input().split()
        m=-int(m)
        l[i][0]=s
        l[i][1]=m
        l[i][2]=i+1
    # eprint(l)
    l.sort()
    # eprint(l)
    for x in l:
        print(x[2])

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
def lcm(n,m):
    return int(n*m/gcd(n,m))

import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop
from queue import PriorityQueue as pq

# from itertools import accumulate
# from collections import deque
import random


def main():
    n = int(input())
    l=[["",0,0] for i in range(n)]
    eprint(l)
    for i in range(n):
        s,m=input().split()
        m=-int(m)
        l[i][0]=s
        l[i][1]=m
        l[i][2]=i+1
    eprint(l)
    l.sort()
    eprint(l)
    for x in l:
        print(x[2])

if __name__ == '__main__':
    main()

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 = sorted(SP, key=lambda x: x[1], reverse=True)
for i in sorted(sp, key=lambda x: x[0]):
    print(i[2])

Submission status: Accepted

Solution code:
N = int(input())

rank_list = []

for i in range(N):
    S, P_str = input().split()
    P = int(P_str)
    rank_list.append([S, -P, i+1])

rank_list.sort()

for rank in rank_list:
    print(rank[2])

Submission status: Accepted

Solution code:
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

# import math
# import string
# import fractions
# from fractions import Fraction
# from fractions import gcd
# def lcm(n,m):
#     return int(n*m/gcd(n,m))

# import re
# # import array
# import copy
# import functools
# import operator

# import collections
# import itertools
# import bisect
# import heapq


# from heapq import heappush
# from heapq import heappop

# # from itertools import accumulate
# # from collections import deque
# import random

from queue import PriorityQueue as pq
# class ReversePriorityQueue(PriorityQueue):
#     def __cmp__(self, other):
#         return -cmp(self.degree, other.degree)
#     # def put(self, tup):
    #     newtup = tup[0] * -1, tup[1]
    #     PriorityQueue.put(self, newtup)

    # def get(self):
    #     tup = PriorityQueue.get(self)
    #     newtup = tup[0] * -1, tup[1]
    #     return newtup

def main():
    n = int(input())
    dict={}
    for i in range(1,n+1):
        str_x,num = input().split()
        num =int(num)
        if (str_x in dict):
            dict[str_x].put((-num,i))
            # dict[str_x].sort(key = lambda x : x[1])
        else:
            a=pq()
            dict[str_x]=a
            dict[str_x].put((-num,i))
            # a.put([num,i])
    eprint(dict)
    ll = sorted(list(dict.items()))
    eprint(ll)
    # for i in ll:
    #     for j in i[1]:
    #         print(j[1])
    for item in ll:
        while item[1].qsize():
            print((item[1].get())[1])
if __name__ == '__main__':
    main()

Submission status: Accepted

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

for _ in range(n):
    sp.append(input().split())

for i in sp:
    i[1]=-int(i[1])
    #文字列と合わせてsortしたら数値は低い順になるので符号逆にすることで実質高い順にできる
    i.append(sp.index(i))
    #今の位置(答える番号)がsp[i][2]に入っていく

sp.sort()

for i in sp:
    print(i[2]+1)
    #0始まりなので1足す

Submission status: Accepted

Solution code:
# coding: utf-8
import os
import time
import re
import math


N = int(input())
SP=[]
for a in range(N):
    temp=input().split()
    SP.append([temp[0],int(temp[1]),(a+1)])
#SP=list(map(lambda x: x[0], SP))
SP.sort(key=lambda x: (x[0],-x[1]))
for a in range(N):
    print(SP[a][2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())


ans = []
index = {}
for i, _ in enumerate(range(N)):
    S, P = input().split()
    ans.append((S, P))
    index[(S, P)] = i + 1

for (S, P) in sorted(ans, key=lambda x: (x[0], -int(x[1]))):
    print(index[(S, P)])

Submission status: Accepted

Solution code:
N = int(input())
dict = {}
for i in range(N):
  list = input().split()
  list[1] = str(int(list[1]) * -1 + 200)
  dict[' '.join(list)] = i
for k, v in sorted(dict.items()):
  print(v + 1)

Submission status: Accepted

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

n = int(input())

a = list()

for i in range(n):
    j, k = input().split()
    k = int(k)
    a.append([i+1, j, k])
a.sort(key=lambda x:(x[1], -x[2]))


for i in a:
    print(i[0])

Submission status: Accepted

Solution code:
from collections import defaultdict

N = int(input())
di = defaultdict(list)

for n in range(1, N + 1):
    S, P = input().split()
    P = int(P)
    di[S].append({n: P})

li = sorted(di.items(), key=lambda x: x[0])

di2 = {}

for tu in li:
    for mini_dict in tu[1]:
        for k, v in mini_dict.items():
            di2[k] = v
    sorted_di2 = sorted(di2.items(), key=lambda x: x[1], reverse=True)
    for tup2 in sorted_di2:
        print(tup2[0])

    sorted_di2 = []
    di2 = {}

Submission status: Accepted

Solution code:
import copy
N = int(input())
sp = [[] for _ in range(N)]
for i in range(N):
    sp[i] = list(input().split())
    sp[i][1] = int(sp[i][1])
alf = []
for v in sp:
    alf.append(v[0])
set(alf)

alf.sort(reverse=True)
for v in sp:
    for i, _v in enumerate(alf):
        if v[0] == _v:
            v[0] = i
_sp = copy.copy(sp)
_sp.sort(reverse=True)

for v in _sp:
    for i, _v in enumerate(sp):
        if v == _v:
            print(i+1)

Submission status: Accepted

Solution code:
n = int(input())

l = [input().split() for _ in range(n)]
for i in l:
    i[1] = -int(i[1])
    i.append(l.index(i))

l.sort()
for i in l:
    print(i[2] + 1)

Submission status: Accepted

Solution code:
import copy
N = int(input())
SP = [[] for _ in range(N)]
for i in range(N):
    SP[i] = list(input().split())
    SP[i][1] = int(SP[i][1])
    
unique = list(set(s[0] for s in SP))
unique.sort(reverse=True)
for i, uni in enumerate(unique):
    for j, S in enumerate(SP):
        if uni == S[0]:
            S[0] = i

copy_SP = copy.copy(SP)
SP.sort(reverse=True)
for i, c in enumerate(SP):
    for j, sp in enumerate(copy_SP):
        if c == sp:
            print(j+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from operator import itemgetter

N = int(input())
l = []
for i in range(N):
        s, p = input().split()
        p = int(p)
        l.append([s,p,1+i])
l.sort(key=itemgetter(0))
L = []
k = l[0][0]
ss = [l[0]]
for i in range(N-1):
        if l[i+1][0] == k :
                ss.append(l[i+1])
        else:
                L.append(ss)
                ss = [l[i+1]]
                k = l[i+1][0]
L.append(ss)
for i in L:
        i.sort(key=itemgetter(1), reverse=True)
for i in L:
        for j in range(len(i)):
                print(i[j][2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input().strip())

list = [input().strip().split() for i in range(N)]

from operator import itemgetter

sort1 = sorted(list, key=lambda x: int(x[1]), reverse=True)
sort2 = sorted(sort1, key=itemgetter(0))

for i in range(N):
    print(list.index(sort2[i]) + 1)

Submission status: Accepted

Solution code:
# -*- coding; utf 8 -*-
# Guidebook
# 2019. 5/28
# 市名をアルファベット順
# 同じ市内なら点数が高い順
# 出力は与えられた番号 (1 origin)


class Guidebook(object):
    def __init__(self, num, city, score):
        self.num = num
        self.city = city
        self.score = score


def print_number(N, guidebook):
    for i in range(N):
        print(guidebook[i].num)


def score_sort(N, guidebook):
    for i in range(N-1):
        for j in range(N-1):
            if guidebook[j].score < guidebook[j+1].score:
                guidebook[j], guidebook[j+1] = (
                    guidebook[j+1], guidebook[j] )


def city_sort(N, guidebook):
    for i in range(N-1):
        for j in range(N-1):
            if str(guidebook[j].city) > str(guidebook[j+1].city):
                guidebook[j], guidebook[j+1] = (
                    guidebook[j+1], guidebook[j] )


if __name__ == '__main__':
    N = int(input()) # number of restaurants
    guidebook = []
    for i in range(N):
        s, p = input().split()
        restaurant = Guidebook(i+1, s, int(p))
        guidebook.append(restaurant)

    score_sort(N, guidebook)
    city_sort(N, guidebook)
    print_number(N, guidebook)

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())
l = []
for i in range(n):
  s,p = input().split()
  l.append((s,int(p),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())
dat = []
for i in range(n):
    s,p = input().split()
    dat.append((s, int(p), i+1))
res = sorted(dat, key=lambda x: (x[0], -x[1]))
for i in range(len(res)):
    print(res[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 n: n[1], reverse=True)
sp.sort(key=lambda n: n[0])

for a in range(n):
    print(sp[a][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 n: n[1], reverse=True)
sp.sort(key=lambda n: n[0])

for c in range(n):
    sp[c].append(c + 1)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sqlite3


connection = sqlite3.connect(':memory:')
cursor = connection.cursor()
cursor.execute("""
CREATE TABLE restaurant (
    id INTEGER,
    city TEXT NOT NULL,
    point INTEGER NOT NULL,
    PRIMARY KEY (id)
);
""")

N = int(input())
for i in range(N):
    Si, Pi = input().split()
    cursor.execute("INSERT INTO restaurant (id, city, point) VALUES ({}, '{}', {});".format(
        i + 1, Si, Pi
    ))

for row in cursor.execute("SELECT id FROM restaurant ORDER BY city ASC, point DESC;"):
    print(row[0])

Submission status: Accepted

Solution code:
n = int(input())
l = [[i for i in input().split()] + [j + 1] for j in range(n)]
l.sort(key=lambda x:x[0])

k = [0]
for i in range(len(l) - 1):
    l[i][1] = int(l[i][1])
    if (l[i][0] != l[i + 1][0]):
        k.append(i + 1)
l[-1][1] = int(l[-1][1])
k.append(len(l))

out = []
for i in range(len(k) - 1):
    a = l[k[i]:k[i + 1]]
    a.sort(reverse=True, key=lambda x:x[1])
    out += a

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

Submission status: Accepted

Solution code:
from operator import itemgetter
n = int(input())
s = []
for i in range(n) :
	a,b = input().split()
	s.append([i+1,a,int(b)])
s.sort(key=itemgetter(2),reverse=True)
s.sort(key=itemgetter(1))
print("\n".join(str(s[i][0]) for i in range(n)))

Submission status: Accepted

Solution code:
from operator import itemgetter

N = int(input())
S = []
for i in range(N):
  tmp = list(input().split())
  S.append([i+1, tmp[0], int(tmp[1])])

S.sort(key=itemgetter(2),reverse=True)
S.sort(key=itemgetter(1))

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

Submission status: Accepted

Solution code:
n = int(input())
restraunt = [[] for i in range(n)]
for i in range(n):
    s, p = input().split()
    p = int(p)
    restraunt[i] = [i+1, s, -p]
restraunt.sort(key = lambda restraunt: (restraunt[1], restraunt[2]))
for i in range(n):
    print(restraunt[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] = str(100 - int(SP[i][1])).rjust(3,'0')
SP2 = []
for i in range(n):
    SP2.append(SP[i][0]+SP[i][1])
ans = sorted(range(len(SP2)), key=lambda k: SP2[k])
for i in ans:
    print(i+1)

Submission status: Accepted

Solution code:
N = int(input())
SP = []
for _ in range(N):
    SP.append([i for i in input().split()])
for n in range(N):
    SP[n][1] = str(100 - int(SP[n][1])).rjust(3,'0')
SP2 = []
for n in range(N):
    SP2.append(SP[n][0]+SP[n][1])
ans = sorted(range(len(SP2)), key=lambda k: SP2[k])
for i in ans:
    print(i+1)

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 s, p, x in sp:
    print(x)

Submission status: Accepted

Solution code:
n = int(input())

restaurant = {}

for i in range(n):
    city, point = input().split()
    point = -int(point)
    restaurant[i] = (city, point)
    
restaurant = sorted(restaurant.items(), key=lambda x: x[1])

for i in restaurant:
    print(i[0]+1)

Submission status: Accepted

Solution code:
from collections import defaultdict


def main():
    n = int(input())
    d = defaultdict(list)
    for i in range(n):
        k, v = input().split()
        d[k].append((int(v), i+1))
    for k in sorted(d.keys()):
        for v in sorted(d[k], key=lambda x: x[0], reverse=True):
            print(v[1])

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#from operator import itemgetter
n = int(input())
d = []

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

#整数は*(-1)をしてそーとした時に昇順にできればいい>通し番号が正しければ良い
d.sort()#list.sort(key=itemgetter(要素番号))＜デフォルト

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

Submission status: Accepted

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

Submission status: Accepted

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

for j in range(len(ls)):
    print(ls[j][0])

Submission status: Accepted

Solution code:
N=int(input())
List=[[0 for i in range(3)] for j in range(N)]
for i in range(N):
  S,P=input().split()
  List[i][0]=i+1
  List[i][1]=S
  List[i][2]=int(P)
List.sort(key=lambda x:x[2],reverse=True)
List.sort(key=lambda x:x[1])
for i in range(N):
  print(List[i][0])

Submission status: Accepted

Solution code:
from operator import itemgetter
print('\n'.join([l[2] for l in sorted([[l[0], -int(l[1]), str(l[2] + 1)] for l in [input().split() + [i] for i in range(int(input()))]],key=itemgetter(0, 1))]))

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()
for b in a:
    print(b[2])

Submission status: Accepted

Solution code:
# ABC128 - B - Guidebook

N = int(input())
List = [[0 for i in range(3)] for j in range(N)]
for i in range(N):
    S,P=input().split()
    List[i][0] = i+1
    List[i][1] = S
    List[i][2] = int(P)
    
List.sort(key=lambda x:x[2], reverse=True)  # 点数について降順
List.sort(key=lambda x:x[1])  # 市名について昇順

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

Submission status: Accepted

Solution code:
# Guidebook https://atcoder.jp/contests/abc128/tasks/abc128_b

N = int(input())

P = [[0 for i in range(3)] for j in range(N)]

for i in range(N):
    P[i][0],P[i][1]  = input().split()
    P[i][1] = 100 - int(P[i][1])
    P[i][2] = i + 1

P.sort()

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

Submission status: Accepted

Solution code:
d = {}
n = int(input())
for i in range(n):
	s, x = input().split()
	x = int(x)
	if s in d:
		d[s].append([x, i])
	else:
		d[s] = [[x, i]]
a = []
for key in d:
	b = d[key]
	b.sort(reverse = True)
	a.append([key, b])
a.sort()
for x in a:
	for y in x[1]:
		print(y[1] + 1)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))

n = int(input())
t = [0] * n
for i in range(n):
    s, p = input().split()
    t[i] = (s, -int(p), i+1)

for i in sorted(t):
    print(i[2])

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))

n = int(input())
s = [0] * n
p = [0] * n
for i in range(n):
    s[i], p[i] = input().split()
    p[i] = -(int(p[i]))

for i in sorted(zip(s,p,range(n))):
    print(i[2]+1)

Submission status: Accepted

Solution code:
#B

n = int(input())
S=[]

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

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

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

Submission status: Accepted

Solution code:
from operator import itemgetter
N = int(input())
S = [""] * N
P = [0] * N
P2 = [""] * N
NUM = [0] * N
lst = [""] * N
for i in range(0, N):
    S[i], P2[i] = map(str, input().split())
    P[i] = int(P2[i])
    NUM[i] = i + 1
    lst[i] = (S[i], P[i], NUM[i])
sorted1 = sorted(lst, key=itemgetter(1), reverse=True)
sorted2 = sorted(sorted1, key=itemgetter(0))
for i in range(0,N):
     print(sorted2[i][2])

Submission status: Accepted

Solution code:
import functools as f

def to_num(a, b):
    if a > b:
        return 1
    if b > a:
        return -1
    return 0

def cmp(a, b):
    if (a[0] == b[0]):
        return to_num(b[1], a[1])
    return to_num(a[0], b[0])

n = int(input())
A = []
for i in range(n):
    a, b = input().split()
    A.append([a, int(b), i + 1])
#print(A)
A.sort(key=f.cmp_to_key(cmp))
for i in range(n):
    print(A[i][2])
#for i in range(n):

Submission status: Accepted

Solution code:
print('\n'.join([l[2] for l in sorted(sorted([[l[0], int(l[1]), str(l[2] + 1)] for l in (input().split() + [i] for i in range(int(input())))], key=lambda l: l[1], reverse=True), key=lambda l: l[0])]))

Submission status: Accepted

Solution code:
#B
N = int(input())
S = [""] * N
P = [0] * N
P2 = [""] * N
NUM = [0] * N
for i in range(0, N):
    S[i], P2[i] = map(str, input().split())
    P[i] = int(P2[i])
    NUM[i] = i + 1
for i in range(0, N):
    for j in range(1, N):
        if S[j] < S[j-1]:
            S[j-1], S[j] = S[j], S[j-1]
            P[j-1], P[j] = P[j], P[j-1]
            NUM[j-1], NUM[j] = NUM[j], NUM[j-1]
        if S[j] == S[j-1]:
            if P[j] > P[j-1]:
                S[j-1], S[j] = S[j], S[j-1]
                P[j-1], P[j] = P[j], P[j-1]
                NUM[j-1], NUM[j] = NUM[j], NUM[j-1]
for i in range(0,N):
    print(NUM[i])

Submission status: Accepted

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

print('\n'.join([str(t[2]+1) for t in sorted(l)]))

Submission status: Accepted

Solution code:
import sys
import bisect
from collections import defaultdict

ans=0
n=int(input())
a=[]
for i in range(n):
    #s,p=map(int,input().split())
    s,p=input().split()
    a.append((s,-int(p),i+1))
#a=[(1,int(i)) for i in input().split()]
a=sorted(a)

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

Submission status: Accepted

Solution code:
N = int(input())
A = []
B = []
C = []
for i in range(N):
    n,a=input().split()
    A.append(n)
    B.append(int(a))  
    C.append(i)
for i in range(N):
    c = i
    for k in range(i+1,N):
        if A[i] > A[k]:
            l = B[k]
            B[k] = B[i]
            B[i] = l
            l = A[k]
            A[k] = A[i]
            A[i] = l
            l = C[k]
            C[k] = C[i]
            C[i] = l
            
        elif A[i] == A[k]:
            if B[i] < B[k]:
                l = B[k]
                B[k] = B[i]
                B[i] = l
                l = A[k]
                A[k] = A[i]
                A[i] = l
                l = C[k]
                C[k] = C[i]
                C[i] = l
               

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

Submission status: Accepted

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

Submission status: Accepted

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

for x in sorted((S, -int(P), i) for i, (S, P) in enumerate(SP, 1)):
    print(x[2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
N = int(sys.stdin.readline())
R = {}
for i in xrange(N):
  s, p = sys.stdin.readline().strip().split()
  if s in R:
    R[s] += [(int(p), i+1)]
  else:
    R[s] = [(int(p), i+1)]
for k,V in sorted(R.items()):
  for v in sorted(V, reverse=True):
    print v[1]

Submission status: Accepted

Solution code:
from operator import itemgetter

N = int(input())
ins = [list(input().split()) for _ in range(N)]

res = []
for i, row in enumerate(ins):
    row = [i+1] + [row[0]] + [int(row[1])]
    res.append(row)

# 点数でソート
res.sort(key=itemgetter(2), reverse=True)

# 市名で辞書式ソート
res.sort(key=itemgetter(1))

for i in res:
    print(i[0])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Mon May 27 22:22:26 2019

@author: Yamazaki Kenichi
"""
def _int(x):
    try:
        return int(x)
    except:
        return x

N = int(input())
sp = [list(map(_int,input().split()))+[i+1] for i in range(N)]

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Mon May 27 22:22:26 2019

@author: Yamazaki Kenichi
"""
def _int(x):
    try:
        return -int(x)
    except:
        return x

N = int(input())
sp = [list(map(_int,input().split()))+[i+1] for i in range(N)]

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

sp.sort()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
numList=[i+1 for i in range(n)]
strList=[]
pointList=[]
for i in range(n):
  s,p = input().split()
  strList.append(s)
  pointList.append(-int(p))
lists = zip(strList,pointList,numList)
q=sorted(lists)
c,a,b = zip(*q)
for x in b:
  print(int(x))

Submission status: Accepted

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

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

for n in range(N):
    print(S_P[n][2])

Submission status: Accepted

Solution code:
N=int(input())
S=[]
P=[]
lst=[]
for i in range(N):
    s,p=input().split()
    lst+=[(s,int(p)*(-1),i+1)]

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

Submission status: Accepted

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

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    L = [0] * N
    for i in range(N):
        s, p = i2s().split()
        L[i] = (s, int(p), i + 1)

    L.sort(key=lambda x: (x[0], -x[1]))
    for l in L:
        print(l[2])

main()

Submission status: Accepted

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

sp.sort()
for item in sp:
    print(item[1])

Submission status: Accepted

Solution code:
import sys

N = int(sys.stdin.readline())

l = {}
for i in range(0, N):
    s, p = sys.stdin.readline().split(" ")
    p = int(p)
    if s not in l:
        l[s] = []
    l[s].append([i, p])


l = sorted(l.items(), key=lambda x: x[0])
for ll in l:
    r = sorted(ll[1], key=lambda x: x[1], reverse=True)
    for rr in r:
        print(rr[0] + 1)

Submission status: Accepted

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

for i in range(n):
    x, y = input().split()
    y = int(y)
    sp.append((x, y, i))

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

for x, y, i in sp:
    print(i+1)