62882023-11-13 13:45:37aballaForgó rulettkerékcpp17Time limit exceeded 35/1001.572s21044 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[i] == ids[n-j-1]) {
                cachecount++;
                ids[n-j-1] = "#";
            }
        }
        count = count + (cachecount*(cachecount+1))/2;
    }
    std::cout << count;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1828 KiB
2Accepted3ms2056 KiB
subtask220/20
3Accepted3ms2284 KiB
4Accepted3ms2508 KiB
5Accepted3ms2728 KiB
6Accepted3ms2956 KiB
7Accepted3ms2896 KiB
8Accepted3ms3228 KiB
9Accepted3ms3184 KiB
subtask315/15
10Accepted18ms4012 KiB
11Accepted23ms4272 KiB
12Accepted21ms4348 KiB
13Accepted17ms4388 KiB
14Accepted20ms4696 KiB
15Accepted24ms4564 KiB
16Accepted24ms4696 KiB
17Accepted24ms4800 KiB
subtask40/65
18Accepted48ms6344 KiB
19Accepted54ms6156 KiB
20Accepted201ms6108 KiB
21Accepted68ms6364 KiB
22Accepted57ms6648 KiB
23Accepted120ms6368 KiB
24Accepted71ms6540 KiB
25Accepted906ms6656 KiB
26Accepted778ms21044 KiB
27Accepted384ms8408 KiB
28Time limit exceeded1.557s5476 KiB
29Time limit exceeded1.572s12680 KiB
30Time limit exceeded1.549s12676 KiB