| Task: | Anagrams |
| Sender: | MrAurela |
| Submission time: | 2020-09-26 14:31:33 +0300 |
| Language: | Python3 (CPython3) |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | WRONG ANSWER | 0.39 s | details |
| #2 | WRONG ANSWER | 1.67 s | details |
| #3 | WRONG ANSWER | 0.67 s | details |
| #4 | WRONG ANSWER | 1.68 s | details |
| #5 | ACCEPTED | 1.90 s | details |
| #6 | ACCEPTED | 1.91 s | details |
| #7 | ACCEPTED | 0.02 s | details |
| #8 | ACCEPTED | 0.02 s | details |
| #9 | ACCEPTED | 0.02 s | details |
Code
n = int(input())
groups = {}
alones = {}
alphabet = {
"a": 0, "b": 1, "c": 2, "d": 3, "e": 4,
"f": 5, "g": 6, "h": 7, "i": 8, "j": 9,
"k": 10, "l": 11, "m": 12, "n": 13, "o": 14,
"p": 15, "q": 16, "r": 17, "s": 18, "t": 19,
"u": 20, "v": 21, "w": 22, "x": 23, "y": 24, "z": 25
}
primes = [
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
73, 79, 83, 89, 97, 101
]
modulo = 100000007
for i in range(n):
word = input()
h = 1
for c in word:
h = h * primes[alphabet[c]] % modulo
if h not in alones:
alones[h] = word
else:
if h not in groups:
groups[h] = [alones[h]]
groups[h].append(word)
print(len(groups))
for group, elements in groups.items():
print(len(elements))
print("\n".join(elements))
Test details
Test 1
Verdict: WRONG ANSWER
| input |
|---|
| 68760 aakkonen aakkosellinen aakkosellisesti aakkosellisuus ... |
| correct output |
|---|
| 3076 2 haaraantua raahaantua 2 ... |
| user output |
|---|
| 3112 2 aikanaan ainakaan 2 ... Truncated |
Test 2
Verdict: WRONG ANSWER
| input |
|---|
| 370099 a aa aaa aah ... |
| correct output |
|---|
| 30178 2 basiparachromatin marsipobranchiata 2 ... |
| user output |
|---|
| 30736 2 abdali abidal 2 ... Truncated |
Test 3
Verdict: WRONG ANSWER
| input |
|---|
| 100000 cnhmuewgnum dxkmhzhetnmxadtcy hfjqwavsiguwpludsketibe xwxolrmvkz ... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 54 2 vkzomecxyzsidwevjlqlcnuew qozmsopxyuyckmslf 2 ... Truncated |
Test 4
Verdict: WRONG ANSWER
| input |
|---|
| 400000 vlcsa eltwde wdcwwkubs tmuxbirj ... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 707 2 fyqzvcuzdmr bnhlspsnav 2 ... Truncated |
Test 5
Verdict: ACCEPTED
| input |
|---|
| 400000 ebhfigdacjlk aecfdijlhkgb jfekhbidacgl cehajbidfklg ... |
| correct output |
|---|
| 1 400000 abcdeighjlfk abcdeiglhfjk abcdfkilejgh ... |
| user output |
|---|
| 1 400000 ebhfigdacjlk aecfdijlhkgb jfekhbidacgl ... Truncated |
Test 6
Verdict: ACCEPTED
| input |
|---|
| 400000 cbaabghadefb hbbgfaeabdac abaedcbgfbha hcfadbbbeaag ... |
| correct output |
|---|
| 1 400000 aaabbbcfegdh aaabbbcfghed aaabbbdcgfhe ... |
| user output |
|---|
| 1 400000 cbaabghadefb hbbgfaeabdac abaedcbgfbha ... Truncated |
Test 7
Verdict: ACCEPTED
| input |
|---|
| 1 a |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 8
Verdict: ACCEPTED
| input |
|---|
| 2 ab ba |
| correct output |
|---|
| 1 2 ab ba |
| user output |
|---|
| 1 2 ab ba |
Test 9
Verdict: ACCEPTED
| input |
|---|
| 2 aa ab |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
