Submission details
Task:Anagrams
Sender:MrAurela
Submission time:2020-09-26 14:16:17 +0300
Language:Python3 (CPython3)
Status:READY
Result:
Test results
testverdicttime
#10.02 sdetails
#20.02 sdetails
#30.02 sdetails
#40.02 sdetails
#50.02 sdetails
#60.02 sdetails
#70.02 sdetails
#80.02 sdetails
#90.02 sdetails

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
}

for i in range(n):
    word = input()
    chars = [0] * 26
    for c in word:
        chars[alphabet.index(c)] += 1
    group = " ".join([str(char) for char in chars])

    if group not in alones:
        alones[group] = word
    else:
        if group not in groups:
            groups[group] = [alones[group]]
        groups[group].append(word)

print(len(groups))
for group, elements in groups.items():
    print(len(elements))
    print("\n".join(elements))

Test details

Test 1

Verdict:

input
68760
aakkonen
aakkosellinen
aakkosellisesti
aakkosellisuus
...

correct output
3076
2
haaraantua
raahaantua
2
...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 18, in <module>
    chars[...

Test 2

Verdict:

input
370099
a
aa
aaa
aah
...

correct output
30178
2
basiparachromatin
marsipobranchiata
2
...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 18, in <module>
    chars[...

Test 3

Verdict:

input
100000
cnhmuewgnum
dxkmhzhetnmxadtcy
hfjqwavsiguwpludsketibe
xwxolrmvkz
...

correct output
0

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 18, in <module>
    chars[...

Test 4

Verdict:

input
400000
vlcsa
eltwde
wdcwwkubs
tmuxbirj
...

correct output
0

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 18, in <module>
    chars[...

Test 5

Verdict:

input
400000
ebhfigdacjlk
aecfdijlhkgb
jfekhbidacgl
cehajbidfklg
...

correct output
1
400000
abcdeighjlfk
abcdeiglhfjk
abcdfkilejgh
...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 18, in <module>
    chars[...

Test 6

Verdict:

input
400000
cbaabghadefb
hbbgfaeabdac
abaedcbgfbha
hcfadbbbeaag
...

correct output
1
400000
aaabbbcfegdh
aaabbbcfghed
aaabbbdcgfhe
...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 18, in <module>
    chars[...

Test 7

Verdict:

input
1
a

correct output
0

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 18, in <module>
    chars[...

Test 8

Verdict:

input
2
ab
ba

correct output
1
2
ab
ba

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 18, in <module>
    chars[...

Test 9

Verdict:

input
2
aa
ab

correct output
0

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 18, in <module>
    chars[...