Submission details
Task:Aristocracy
Sender:Works on my Machine
Submission time:2025-11-08 13:10:17 +0200
Language:Python3 (PyPy3)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.04 sdetails
#20.04 sdetails
#3ACCEPTED0.04 sdetails
#40.04 sdetails
#50.07 sdetails
#6ACCEPTED0.33 sdetails
#70.26 sdetails
#80.29 sdetails
#90.27 sdetails
#100.31 sdetails
#11ACCEPTED0.33 sdetails
#120.26 sdetails
#130.29 sdetails
#140.27 sdetails
#150.33 sdetails
#160.32 sdetails
#17ACCEPTED0.05 sdetails

Code

import math

n = int(input())

m = {}
for _ in range(0, n):
    s = input()
    v = s.split()
    k = v[0]
    v = int(v[1])
    if k in m:
        m[k]+=1
    else:
        m[k]=1 

rtn = math.factorial(n)

for _, x in m.items():
    rtn /= math.factorial(x)

#print(1e9+7)
#print(10**9+7)


print(int(rtn % (1e9+7)))

Test details

Test 1

Verdict: ACCEPTED

input
4
Uolevi 1
Maija 3
Uolevi 2
Maija 2

correct output
6

user output
6

Test 2

Verdict:

input
31
Eric 9
Charles 7
Sverker 2
Eric 10
...

correct output
541197645

user output
481502285

Feedback: Incorrect character on line 1 col 1: expected "541197645", got "481502285"

Test 3

Verdict: ACCEPTED

input
19
Ivan 4
Feodor 1
Feodor 2
Dmitry 1
...

correct output
939302456

user output
939302456

Test 4

Verdict:

input
41
William 1
William 2
Henry 1
Stephen 1
...

correct output
520019025

user output
860648197

Feedback: Incorrect character on line 1 col 1: expected "520019025", got "860648197"

Test 5

Verdict:

input
216
Peter 1
Linus 1
Cletus 1
Clement 1
...

correct output
200519221

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 19, in <module>
    rtn /= math.factorial(x)
OverflowError: integer division result too large for a float

Test 6

Verdict: ACCEPTED

input
100000
A 1
A 2
A 3
A 4
...

correct output
1

user output
1

Test 7

Verdict:

input
100000
E 1
Y 1
Y 2
M 1
...

correct output
504127783

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 19, in <module>
    rtn /= math.factorial(x)
OverflowError: integer division result too large for a float

Test 8

Verdict:

input
100000
Maija 1
Uolevi 1
Maija 2
Maija 3
...

correct output
328286172

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 19, in <module>
    rtn /= math.factorial(x)
OverflowError: integer division result too large for a float

Test 9

Verdict:

input
100000
Maijx 1
Maije 1
Maijw 1
Maijp 1
...

correct output
178134668

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 19, in <module>
    rtn /= math.factorial(x)
OverflowError: integer division result too large for a float

Test 10

Verdict:

input
100000
Bwvfj 1
Zmcpk 1
Jnmhz 1
Vcqtv 1
...

correct output
804665298

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 19, in <module>
    rtn /= math.factorial(x)
OverflowError: integer division result too large for a float

Test 11

Verdict: ACCEPTED

input
100000
A 947476077
A 209406366
A 64254608
A 370109404
...

correct output
1

user output
1

Test 12

Verdict:

input
100000
F 779918796
L 978222897
L 977989517
O 263870841
...

correct output
903086284

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 19, in <module>
    rtn /= math.factorial(x)
OverflowError: integer division result too large for a float

Test 13

Verdict:

input
100000
Maija 968540665
Uolevi 869194539
Uolevi 530855688
Maija 232728327
...

correct output
271775549

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 19, in <module>
    rtn /= math.factorial(x)
OverflowError: integer division result too large for a float

Test 14

Verdict:

input
100000
Uolevj 501874596
Uolevm 133829533
Uolevd 13322011
Uolevw 418508186
...

correct output
529945879

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 19, in <module>
    rtn /= math.factorial(x)
OverflowError: integer division result too large for a float

Test 15

Verdict:

input
100000
Hamql 748803883
Mpfaf 709208011
Gegcd 685359815
Yvain 890816531
...

correct output
166192905

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 19, in <module>
    rtn /= math.factorial(x)
OverflowError: integer division result too large for a float

Test 16

Verdict:

input
100000
Barmfsykcm 225712723
Xmvycwxssc 893904167
Wpetqrazdz 316367309
Eatxvkieif 111661228
...

correct output
457992974

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 19, in <module>
    rtn /= math.factorial(x)
OverflowError: integer division result too large for a float

Test 17

Verdict: ACCEPTED

input
1
Ltwgcnsajxaxhacysdjhrpzymwxaen...

correct output
1

user output
1