62872023-11-13 13:39:10aballaForgó rulettkerékcpp17Time limit exceeded 35/1001.575s12188 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() {
    int count = 0, cachecount;
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::string cache, cache2;
    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++) {
        if (ids[i] == "#") {continue;}
        cachecount = 0;

        for (int j = 0; j < n-i-1; j++) {
            if (ids[n-j-1] == "#") {continue;}
            
            if(ids[i] == ids[n-j-1]) {
                cachecount++;
                ids[n-j-1] = "#";
            }
        }
        count = count + (cachecount*(cachecount+1))/2;
    }
    std::cout << count;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1828 KiB
2Accepted3ms2020 KiB
subtask220/20
3Accepted3ms2244 KiB
4Accepted3ms2480 KiB
5Accepted3ms2688 KiB
6Accepted3ms3064 KiB
7Accepted3ms3256 KiB
8Accepted3ms3192 KiB
9Accepted3ms3208 KiB
subtask315/15
10Accepted17ms3816 KiB
11Accepted21ms4128 KiB
12Accepted21ms4264 KiB
13Accepted17ms4064 KiB
14Accepted20ms4240 KiB
15Accepted25ms4512 KiB
16Accepted25ms4596 KiB
17Accepted25ms4812 KiB
subtask40/65
18Accepted63ms6360 KiB
19Accepted71ms5964 KiB
20Accepted201ms5748 KiB
21Accepted71ms6328 KiB
22Accepted71ms6488 KiB
23Accepted119ms6172 KiB
24Accepted104ms6412 KiB
25Accepted907ms6352 KiB
26Time limit exceeded1.575s11996 KiB
27Accepted1.019s8204 KiB
28Time limit exceeded1.565s5144 KiB
29Time limit exceeded1.565s12188 KiB
30Time limit exceeded1.562s12152 KiB