62792023-11-12 12:32:49HadaGergelyForgó rulettkerékpython3Runtime error 0/10021ms14560 KiB
n = int(input()) # num of lines
m = int(input()) # length of lines

all = []

for x in range(n):
    all.append(input().split(""))


types = []
type_counter = []

types[0]=all[0]
type_counter[0] = 1

for x in range(n):

    temp_type_counter = type_counter

    for y in range(len(types)):

        if all[x].sort() != types[y].sort(): continue
        else:
            temp = all[x]

            for z in range(m):
                if temp == types[y]:
                    type_counter[y] = type_counter[y] + 1
                    break
                temp.append(temp[0])
                temp.pop(0)
                
            
    if temp_type_counter == type_counter:
        types.append(all[x])
        type_counter.append(1)

answer = 0

for l in range(len(type_counter)):
    answer = answer + ((type_counter[l]*(type_counter[l]-1))/2)

print(answer)
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Runtime error17ms11184 KiB
2Runtime error18ms11228 KiB
subtask20/20
3Runtime error18ms11512 KiB
4Runtime error18ms11760 KiB
5Runtime error18ms11772 KiB
6Runtime error17ms12088 KiB
7Runtime error18ms12496 KiB
8Runtime error18ms12468 KiB
9Runtime error18ms12668 KiB
subtask30/15
10Runtime error17ms12560 KiB
11Runtime error17ms12808 KiB
12Runtime error17ms12984 KiB
13Runtime error17ms13044 KiB
14Runtime error18ms12816 KiB
15Runtime error19ms13044 KiB
16Runtime error19ms13036 KiB
17Runtime error17ms13124 KiB
subtask40/65
18Runtime error18ms13288 KiB
19Runtime error21ms13480 KiB
20Runtime error18ms13568 KiB
21Runtime error18ms13516 KiB
22Runtime error18ms13712 KiB
23Runtime error17ms13844 KiB
24Runtime error17ms13984 KiB
25Runtime error18ms13724 KiB
26Runtime error17ms13940 KiB
27Runtime error17ms14148 KiB
28Runtime error17ms14292 KiB
29Runtime error17ms14464 KiB
30Runtime error17ms14560 KiB