62932023-11-13 15:50:35aballaForgó rulettkerékcpp17Wrong answer 0/1001.559s27596 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, cc = 0;
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::string cache;
    std::vector<std::string> ids;
    std::vector<int> veccount;
    std::unordered_map<std::string, int> map;

    std::cin >> n >> m;
    for(int i = 0; i < n; i++) {
        std::cin >> cache; 
        ids.push_back(tagid(cache));
    }
    map.insert({ids[0], 0});
    veccount.push_back(0);
    for(int i = 0; i < n; i++) {
        if (auto search = map.find(ids[i]); search != map.end()) {
            veccount[search->second]++;
        }
        else {
            map.insert({ids[i], cc});
            veccount.push_back(1);
            cc++;
        }
    }
    for(const auto x : veccount) {
        count += x*(x-1);
    }
    
    std::cout << count/2;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted4ms1972 KiB
2Accepted3ms2180 KiB
subtask20/20
3Accepted3ms2252 KiB
4Accepted3ms2612 KiB
5Wrong answer3ms2676 KiB
6Wrong answer3ms3032 KiB
7Accepted3ms3408 KiB
8Wrong answer3ms3320 KiB
9Wrong answer3ms3472 KiB
subtask30/15
10Wrong answer17ms4376 KiB
11Wrong answer21ms4536 KiB
12Wrong answer20ms4696 KiB
13Wrong answer17ms4356 KiB
14Accepted20ms4544 KiB
15Accepted23ms5228 KiB
16Accepted23ms5472 KiB
17Accepted21ms5408 KiB
subtask40/65
18Wrong answer45ms6416 KiB
19Wrong answer43ms6552 KiB
20Wrong answer200ms6660 KiB
21Wrong answer65ms7136 KiB
22Wrong answer50ms7100 KiB
23Accepted119ms6484 KiB
24Wrong answer48ms7516 KiB
25Wrong answer902ms6976 KiB
26Wrong answer74ms21224 KiB
27Wrong answer54ms9572 KiB
28Time limit exceeded1.559s5468 KiB
29Accepted79ms21176 KiB
30Wrong answer104ms27596 KiB