62902023-11-13 13:52:08aballaForgó rulettkerékcpp17Time limit exceeded 35/1001.565s12676 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++) {
            if(ids[i] == ids[n-j-1]) count++;
        }
    }
    std::cout << count;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1832 KiB
2Accepted3ms2056 KiB
subtask220/20
3Accepted3ms2272 KiB
4Accepted3ms2480 KiB
5Accepted3ms2536 KiB
6Accepted3ms2800 KiB
7Accepted3ms3016 KiB
8Accepted3ms3248 KiB
9Accepted3ms3536 KiB
subtask315/15
10Accepted18ms4444 KiB
11Accepted25ms4456 KiB
12Accepted21ms4540 KiB
13Accepted18ms4360 KiB
14Accepted24ms4572 KiB
15Accepted24ms4700 KiB
16Accepted23ms4696 KiB
17Accepted23ms4888 KiB
subtask40/65
18Accepted123ms6440 KiB
19Accepted126ms6408 KiB
20Accepted199ms6208 KiB
21Accepted68ms6556 KiB
22Accepted90ms6500 KiB
23Accepted120ms6548 KiB
24Accepted79ms6716 KiB
25Accepted904ms6940 KiB
26Time limit exceeded1.565s12244 KiB
27Accepted1.151s8572 KiB
28Time limit exceeded1.56s5236 KiB
29Time limit exceeded1.565s12308 KiB
30Time limit exceeded1.557s12676 KiB