| Task: | Aristocracy |
| Sender: | Casinosort |
| Submission time: | 2025-11-08 16:12:19 +0200 |
| Language: | Python3 (PyPy3) |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.04 s | details |
| #2 | WRONG ANSWER | 0.04 s | details |
| #3 | WRONG ANSWER | 0.04 s | details |
| #4 | WRONG ANSWER | 0.04 s | details |
| #5 | WRONG ANSWER | 0.05 s | details |
| #6 | WRONG ANSWER | 0.13 s | details |
| #7 | TIME LIMIT EXCEEDED | -- | details |
| #8 | WRONG ANSWER | 0.30 s | details |
| #9 | TIME LIMIT EXCEEDED | -- | details |
| #10 | WRONG ANSWER | 0.22 s | details |
| #11 | WRONG ANSWER | 0.13 s | details |
| #12 | TIME LIMIT EXCEEDED | -- | details |
| #13 | WRONG ANSWER | 0.30 s | details |
| #14 | TIME LIMIT EXCEEDED | -- | details |
| #15 | WRONG ANSWER | 0.23 s | details |
| #16 | WRONG ANSWER | 0.22 s | details |
| #17 | ACCEPTED | 0.05 s | details |
Code
import math
line1= input()
firstname = ""
"""
def groupby(iterable, key=None):
# [k for k, g in groupby('AAAABBBCCDAABBB')] → A B C D A B
# [list(g) for k, g in groupby('AAAABBBCCD')] → AAAA BBB CC D
keyfunc = (lambda x: x) if key is None else key
iterator = iter(iterable)
exhausted = False
def _grouper(target_key):
nonlocal curr_value, curr_key, exhausted
yield curr_value
for curr_value in iterator:
curr_key = keyfunc(curr_value)
if curr_key != target_key:
return
yield curr_value
exhausted = True
try:
curr_value = next(iterator)
except StopIteration:
return
curr_key = keyfunc(curr_value)
while not exhausted:
target_key = curr_key
curr_group = _grouper(target_key)
yield curr_key, curr_group
if curr_key == target_key:
for _ in curr_group:
pass
hessut = []
"""
namecount = dict()
for x in range(0,int(line1)):
nimi = input().split()[0]
if firstname == "":
firstname = nimi
if nimi not in namecount:
namecount[nimi] = 1
else:
namecount[nimi] = namecount[nimi] + 1
#naa = groupby(hessut)
#awe = [list(g) for k,g in groupby(hessut)]
#print(awe)
#main = []
#for i in awe:
# main.append([i[0],len(i)])
#print(main)
d = namecount
#print(d)
n = d.pop(firstname)
#print(n)
res = 1
if len(d) == 0:
print(n)
else:
k = n+1
for i in d.keys():
m = d[i]
if k-1 < m:
temp = m
m = k-1
k = temp+1
res = res * ((k**m) - math.comb(k, m))
k = k + m
print(res)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: WRONG ANSWER
| input |
|---|
| 31 Eric 9 Charles 7 Sverker 2 Eric 10 ... |
| correct output |
|---|
| 541197645 |
| user output |
|---|
| 0 |
Feedback: Incorrect character on line 1 col 1: expected "541197645", got "0"
Test 3
Verdict: WRONG ANSWER
| input |
|---|
| 19 Ivan 4 Feodor 1 Feodor 2 Dmitry 1 ... |
| correct output |
|---|
| 939302456 |
| user output |
|---|
| 0 |
Feedback: Incorrect character on line 1 col 1: expected "939302456", got "0"
Test 4
Verdict: WRONG ANSWER
| input |
|---|
| 41 William 1 William 2 Henry 1 Stephen 1 ... |
| correct output |
|---|
| 520019025 |
| user output |
|---|
| 0 |
Feedback: Incorrect character on line 1 col 1: expected "520019025", got "0"
Test 5
Verdict: WRONG ANSWER
| input |
|---|
| 216 Peter 1 Linus 1 Cletus 1 Clement 1 ... |
| correct output |
|---|
| 200519221 |
| user output |
|---|
| 0 |
Feedback: Incorrect character on line 1 col 1: expected "200519221", got "0"
Test 6
Verdict: WRONG ANSWER
| input |
|---|
| 100000 A 1 A 2 A 3 A 4 ... |
| correct output |
|---|
| 1 |
| user output |
|---|
| 100000 |
Feedback: Incorrect character on line 1 col 2: expected "1", got "100000"
Test 7
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 100000 E 1 Y 1 Y 2 M 1 ... |
| correct output |
|---|
| 504127783 |
| user output |
|---|
| (empty) |
Test 8
Verdict: WRONG ANSWER
| input |
|---|
| 100000 Maija 1 Uolevi 1 Maija 2 Maija 3 ... |
| correct output |
|---|
| 328286172 |
| user output |
|---|
| 375296986374085239349318971323... |
Feedback: Incorrect character on line 1 col 2: expected "328286172", got "375296986374..."
Test 9
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 100000 Maijx 1 Maije 1 Maijw 1 Maijp 1 ... |
| correct output |
|---|
| 178134668 |
| user output |
|---|
| (empty) |
Test 10
Verdict: WRONG ANSWER
| input |
|---|
| 100000 Bwvfj 1 Zmcpk 1 Jnmhz 1 Vcqtv 1 ... |
| correct output |
|---|
| 804665298 |
| user output |
|---|
| 0 |
Feedback: Incorrect character on line 1 col 1: expected "804665298", got "0"
Test 11
Verdict: WRONG ANSWER
| input |
|---|
| 100000 A 947476077 A 209406366 A 64254608 A 370109404 ... |
| correct output |
|---|
| 1 |
| user output |
|---|
| 100000 |
Feedback: Incorrect character on line 1 col 2: expected "1", got "100000"
Test 12
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 100000 F 779918796 L 978222897 L 977989517 O 263870841 ... |
| correct output |
|---|
| 903086284 |
| user output |
|---|
| (empty) |
Test 13
Verdict: WRONG ANSWER
| input |
|---|
| 100000 Maija 968540665 Uolevi 869194539 Uolevi 530855688 Maija 232728327 ... |
| correct output |
|---|
| 271775549 |
| user output |
|---|
| 756220554441212158553121111145... |
Feedback: Incorrect character on line 1 col 1: expected "271775549", got "756220554441..."
Test 14
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 100000 Uolevj 501874596 Uolevm 133829533 Uolevd 13322011 Uolevw 418508186 ... |
| correct output |
|---|
| 529945879 |
| user output |
|---|
| (empty) |
Test 15
Verdict: WRONG ANSWER
| input |
|---|
| 100000 Hamql 748803883 Mpfaf 709208011 Gegcd 685359815 Yvain 890816531 ... |
| correct output |
|---|
| 166192905 |
| user output |
|---|
| 0 |
Feedback: Incorrect character on line 1 col 1: expected "166192905", got "0"
Test 16
Verdict: WRONG ANSWER
| input |
|---|
| 100000 Barmfsykcm 225712723 Xmvycwxssc 893904167 Wpetqrazdz 316367309 Eatxvkieif 111661228 ... |
| correct output |
|---|
| 457992974 |
| user output |
|---|
| 0 |
Feedback: Incorrect character on line 1 col 1: expected "457992974", got "0"
Test 17
Verdict: ACCEPTED
| input |
|---|
| 1 Ltwgcnsajxaxhacysdjhrpzymwxaen... |
| correct output |
|---|
| 1 |
| user output |
|---|
| 1 |
