62842023-11-12 14:42:48HadaGergelyForgó rulettkerékpython3Time limit exceeded 20/1001.585s526900 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
1Accepted17ms11180 KiB
2Accepted17ms11532 KiB
subtask220/20
3Accepted18ms11908 KiB
4Accepted18ms11964 KiB
5Accepted39ms13044 KiB
6Accepted128ms15336 KiB
7Accepted430ms28200 KiB
8Accepted134ms15908 KiB
9Accepted179ms17228 KiB
subtask30/15
10Time limit exceeded1.574s51472 KiB
11Time limit exceeded1.583s65044 KiB
12Time limit exceeded1.574s139196 KiB
13Time limit exceeded1.55s65816 KiB
14Time limit exceeded1.565s57812 KiB
15Time limit exceeded1.567s163688 KiB
16Time limit exceeded1.58s175092 KiB
17Time limit exceeded1.585s172368 KiB
subtask40/65
18Time limit exceeded1.582s29288 KiB
19Time limit exceeded1.582s41184 KiB
20Runtime error505ms526840 KiB
21Runtime error1.292s526900 KiB
22Time limit exceeded1.574s59820 KiB
23Runtime error649ms526892 KiB
24Time limit exceeded1.562s81276 KiB
25Runtime error528ms526664 KiB
26Time limit exceeded1.572s29880 KiB
27Time limit exceeded1.585s20980 KiB
28Runtime error397ms526376 KiB
29Time limit exceeded1.565s30404 KiB
30Time limit exceeded1.58s30628 KiB