62772023-11-11 19:51:55aballaForgó rulettkerékcpp11Wrong answer 0/1001.577s11512 KiB
#include <bits/stdc++.h>

int n, m;

bool similar(std::string a, std::string b) {
    const std::string c = a+a;
    std::string str;
    for(int i = 0; i < m; i++) {
        str = std::string(&c[i], &c[i+m]);
        
        if (str == b)
        {
            return 1;
        }
    }
    return 0;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::string cache;
    std::vector<std::string> ids;
    int count = 0;
    int cachecount = 0;

    scanf("%d %d", &n, &m);
    for(int i = 0; i < n; i++) {
        std::cin >> cache; 
        ids.push_back(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(similar(ids[i], ids[n-j-1])) {
                cachecount++;
                ids[n-j-1] = "#";
            }
        }
        count = count + (cachecount*(cachecount+1))/2;
    }
    std::cout << count;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer3ms1828 KiB
2Wrong answer3ms2060 KiB
subtask20/20
3Wrong answer3ms2280 KiB
4Wrong answer3ms2504 KiB
5Wrong answer4ms2600 KiB
6Wrong answer7ms2848 KiB
7Wrong answer17ms3072 KiB
8Wrong answer8ms2960 KiB
9Wrong answer6ms2840 KiB
subtask30/15
10Wrong answer97ms3416 KiB
11Wrong answer79ms3488 KiB
12Wrong answer823ms3584 KiB
13Accepted166ms3800 KiB
14Wrong answer68ms3868 KiB
15Time limit exceeded1.57s2924 KiB
16Time limit exceeded1.557s2812 KiB
17Time limit exceeded1.565s3068 KiB
subtask40/65
18Wrong answer1.386s5916 KiB
19Time limit exceeded1.565s3824 KiB
20Time limit exceeded1.526s3584 KiB
21Time limit exceeded1.574s3796 KiB
22Time limit exceeded1.557s3896 KiB
23Wrong answer666ms5212 KiB
24Time limit exceeded1.557s3716 KiB
25Time limit exceeded1.529s3724 KiB
26Time limit exceeded1.562s11064 KiB
27Time limit exceeded1.554s4784 KiB
28Time limit exceeded1.57s5236 KiB
29Time limit exceeded1.577s11512 KiB
30Time limit exceeded1.57s11132 KiB