62892023-11-13 13:49:27aballaForgó rulettkerékcpp17Wrong answer 0/1001.57s11584 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, 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++) {
        cachecount = 0;

        for (int j = 0; j < n-i-1; j++) {
            if(ids[i] == ids[n-j-1]) {
                cachecount++;
            }
        }
        count = count + (cachecount*(cachecount+1))/2;
    }
    std::cout << count;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer3ms1832 KiB
2Accepted3ms2056 KiB
subtask20/20
3Accepted3ms2272 KiB
4Wrong answer3ms2480 KiB
5Wrong answer3ms2668 KiB
6Wrong answer3ms2764 KiB
7Wrong answer3ms3020 KiB
8Wrong answer3ms2980 KiB
9Wrong answer3ms3232 KiB
subtask30/15
10Wrong answer18ms3880 KiB
11Wrong answer25ms4064 KiB
12Wrong answer21ms3928 KiB
13Wrong answer18ms3744 KiB
14Wrong answer24ms3920 KiB
15Wrong answer24ms4076 KiB
16Accepted23ms4164 KiB
17Wrong answer24ms4376 KiB
subtask40/65
18Wrong answer123ms5844 KiB
19Wrong answer126ms5568 KiB
20Wrong answer200ms5340 KiB
21Wrong answer71ms5660 KiB
22Wrong answer87ms5604 KiB
23Wrong answer119ms5384 KiB
24Wrong answer79ms5556 KiB
25Wrong answer902ms5740 KiB
26Time limit exceeded1.57s11356 KiB
27Wrong answer1.154s7760 KiB
28Time limit exceeded1.557s4396 KiB
29Time limit exceeded1.562s11368 KiB
30Time limit exceeded1.562s11584 KiB