62862023-11-13 13:33:50aballaForgó rulettkerékcpp17Wrong answer 0/1001.582s12688 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, 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
1Wrong answer3ms1700 KiB
2Wrong answer3ms1928 KiB
subtask20/20
3Wrong answer3ms2144 KiB
4Wrong answer3ms2348 KiB
5Wrong answer3ms2584 KiB
6Wrong answer3ms2664 KiB
7Wrong answer3ms3004 KiB
8Wrong answer3ms3064 KiB
9Wrong answer3ms3148 KiB
subtask30/15
10Wrong answer17ms4060 KiB
11Wrong answer21ms4112 KiB
12Wrong answer21ms4228 KiB
13Wrong answer17ms4112 KiB
14Wrong answer20ms4208 KiB
15Wrong answer25ms4356 KiB
16Wrong answer25ms4444 KiB
17Wrong answer25ms4652 KiB
subtask40/65
18Wrong answer64ms6340 KiB
19Wrong answer72ms6296 KiB
20Wrong answer199ms6332 KiB
21Wrong answer71ms6948 KiB
22Wrong answer71ms6676 KiB
23Wrong answer119ms6764 KiB
24Wrong answer105ms6972 KiB
25Wrong answer898ms7184 KiB
26Time limit exceeded1.582s12688 KiB
27Wrong answer1.036s8852 KiB
28Time limit exceeded1.56s5624 KiB
29Time limit exceeded1.565s12400 KiB
30Time limit exceeded1.572s12508 KiB