62812023-11-12 13:29:05HadaGergelyForgó rulettkerékpython3Time limit exceeded 20/1001.601s30064 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 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(int(answer))
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted18ms11124 KiB
2Accepted17ms11452 KiB
subtask220/20
3Accepted18ms11652 KiB
4Accepted18ms11812 KiB
5Accepted32ms12116 KiB
6Accepted82ms12052 KiB
7Accepted270ms12584 KiB
8Accepted86ms12760 KiB
9Accepted119ms12800 KiB
subtask30/15
10Time limit exceeded1.57s7792 KiB
11Time limit exceeded1.562s8656 KiB
12Time limit exceeded1.582s8424 KiB
13Time limit exceeded1.57s8056 KiB
14Time limit exceeded1.57s8536 KiB
15Time limit exceeded1.578s8804 KiB
16Time limit exceeded1.578s8596 KiB
17Time limit exceeded1.539s8864 KiB
subtask40/65
18Time limit exceeded1.575s13300 KiB
19Time limit exceeded1.575s12820 KiB
20Time limit exceeded1.567s13044 KiB
21Time limit exceeded1.575s13720 KiB
22Time limit exceeded1.572s14008 KiB
23Time limit exceeded1.567s13144 KiB
24Time limit exceeded1.58s13452 KiB
25Time limit exceeded1.588s14428 KiB
26Time limit exceeded1.582s29744 KiB
27Time limit exceeded1.555s15692 KiB
28Time limit exceeded1.559s16964 KiB
29Time limit exceeded1.557s29836 KiB
30Time limit exceeded1.601s30064 KiB