62912023-11-13 13:54:29aballaForgó rulettkerékcpp17Time limit exceeded 35/1001.57s11936 KiB
#include <bits/stdc++.h>

int n, m;

std::string tagid(std::string str) {
    std::string s = str + str, k, min;
    min = str;

    for(int i = 1; i < m; i++) {
        k = std::string(&s[i], &s[i+m]);
        if(min > k) min = k;
    }
    return min;
}

int main() {
    long long count = 0;
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::string cache;
    std::vector<std::string> ids;

    std::cin >> n >> m;
    for(int i = 0; i < n; i++) {
        std::cin >> cache; 
        ids.push_back(tagid(cache));
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n-i-1; j++) {
            count += (ids[i] == ids[n-j-1]);
        }
    }
    std::cout << count;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1824 KiB
2Accepted3ms2064 KiB
subtask220/20
3Accepted3ms2296 KiB
4Accepted3ms2512 KiB
5Accepted3ms2736 KiB
6Accepted3ms2828 KiB
7Accepted3ms2956 KiB
8Accepted3ms3020 KiB
9Accepted3ms3364 KiB
subtask315/15
10Accepted19ms3884 KiB
11Accepted26ms4068 KiB
12Accepted23ms3968 KiB
13Accepted18ms4052 KiB
14Accepted25ms4260 KiB
15Accepted24ms4356 KiB
16Accepted24ms4480 KiB
17Accepted24ms4368 KiB
subtask40/65
18Accepted119ms5932 KiB
19Accepted122ms5796 KiB
20Accepted200ms5452 KiB
21Accepted70ms5756 KiB
22Accepted90ms6016 KiB
23Accepted120ms5748 KiB
24Accepted79ms5760 KiB
25Accepted907ms6136 KiB
26Time limit exceeded1.554s11568 KiB
27Accepted1.113s8044 KiB
28Time limit exceeded1.559s5036 KiB
29Time limit exceeded1.57s11936 KiB
30Time limit exceeded1.559s11880 KiB