Submission details
Task:Anagrams
Sender:MrAurela
Submission time:2020-09-26 13:52:07 +0300
Language:Python3 (CPython3)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.83 sdetails
#2--details
#3ACCEPTED1.42 sdetails
#4--details
#5--details
#6--details
#7ACCEPTED0.02 sdetails
#8ACCEPTED0.02 sdetails
#9ACCEPTED0.02 sdetails

Code

n = int(input())

groups = {}
alphabet = "abcdefghijklmnopqrstuvwxyz"

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 groups:
        groups[group] = []
    groups[group].append(word)

print(len([group for group, elements in groups.items() if len(elements) >= 2]))
for group, elements in groups.items():
    if len(elements) >= 2:
        print(len(elements))
        print("\n".join(elements))

Test details

Test 1

Verdict: ACCEPTED

input
68760
aakkonen
aakkosellinen
aakkosellisesti
aakkosellisuus
...

correct output
3076
2
haaraantua
raahaantua
2
...

user output
3076
2
aakkosellinen
kaaoksellinen
2
...
Truncated

Test 2

Verdict:

input
370099
a
aa
aaa
aah
...

correct output
30178
2
basiparachromatin
marsipobranchiata
2
...

user output
(empty)

Test 3

Verdict: ACCEPTED

input
100000
cnhmuewgnum
dxkmhzhetnmxadtcy
hfjqwavsiguwpludsketibe
xwxolrmvkz
...

correct output
0

user output
0

Test 4

Verdict:

input
400000
vlcsa
eltwde
wdcwwkubs
tmuxbirj
...

correct output
0

user output
(empty)

Test 5

Verdict:

input
400000
ebhfigdacjlk
aecfdijlhkgb
jfekhbidacgl
cehajbidfklg
...

correct output
1
400000
abcdeighjlfk
abcdeiglhfjk
abcdfkilejgh
...

user output
(empty)

Test 6

Verdict:

input
400000
cbaabghadefb
hbbgfaeabdac
abaedcbgfbha
hcfadbbbeaag
...

correct output
1
400000
aaabbbcfegdh
aaabbbcfghed
aaabbbdcgfhe
...

user output
(empty)

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