62832023-11-12 14:40:33HadaGergelyForgó rulettkerékpython3Runtime error 0/100333ms61196 KiB
t = input()

n = int(t.split(" ")[0]) # num of lines
m = int(t.split(" ")[1]) # length of lines

all = []

for x in range(n):
    all.append([*input()])


types = []
type_counter = []


for x in range(n):

    temp_type_counter = type_counter.copy()

    for y in range(len(types)):

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

            for z in range(m):
                if all[x] == types[y][z]:
                    type_counter[y] = type_counter[y] + 1
                    break
                """
                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:
        temp = all[x].copy
        temp_2d = []
        for p in range(m):
            temp_2d.append(temp.copy())
            temp.append(temp[0])
            temp.pop(0)
        types.append(temp_2d.copy())
        type_counter.append(1)
        """
        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(int(answer))
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Runtime error17ms11284 KiB
2Runtime error17ms11640 KiB
subtask20/20
3Runtime error17ms11372 KiB
4Runtime error17ms11900 KiB
5Runtime error18ms12252 KiB
6Runtime error17ms12340 KiB
7Runtime error18ms12324 KiB
8Runtime error17ms12500 KiB
9Runtime error17ms12864 KiB
subtask30/15
10Runtime error25ms17592 KiB
11Runtime error26ms18964 KiB
12Runtime error26ms18096 KiB
13Runtime error26ms17564 KiB
14Runtime error27ms18304 KiB
15Runtime error28ms19024 KiB
16Runtime error27ms19020 KiB
17Runtime error27ms19392 KiB
subtask40/65
18Runtime error52ms28256 KiB
19Runtime error48ms27272 KiB
20Runtime error39ms27852 KiB
21Runtime error46ms29296 KiB
22Runtime error52ms29888 KiB
23Runtime error41ms28088 KiB
24Runtime error50ms28628 KiB
25Runtime error41ms29916 KiB
26Runtime error333ms61196 KiB
27Runtime error78ms32584 KiB
28Runtime error41ms30088 KiB
29Runtime error331ms61180 KiB
30Runtime error333ms61128 KiB