62922023-11-13 15:48:48aballaForgó rulettkerékcpp17Wrong answer 0/1001.574s27552 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 << "\n" << count/2;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer3ms1976 KiB
2Wrong answer3ms2024 KiB
subtask20/20
3Wrong answer3ms2196 KiB
4Wrong answer3ms2416 KiB
5Wrong answer3ms2640 KiB
6Wrong answer3ms2740 KiB
7Wrong answer3ms2756 KiB
8Wrong answer3ms2904 KiB
9Wrong answer3ms2868 KiB
subtask30/15
10Wrong answer17ms3696 KiB
11Wrong answer23ms4104 KiB
12Wrong answer20ms4376 KiB
13Wrong answer17ms4192 KiB
14Wrong answer20ms4728 KiB
15Wrong answer23ms5612 KiB
16Wrong answer23ms5768 KiB
17Wrong answer23ms5708 KiB
subtask40/65
18Wrong answer45ms6660 KiB
19Wrong answer41ms6796 KiB
20Wrong answer200ms7016 KiB
21Wrong answer65ms7540 KiB
22Wrong answer50ms7288 KiB
23Wrong answer119ms6604 KiB
24Wrong answer48ms7576 KiB
25Wrong answer911ms6960 KiB
26Wrong answer75ms21336 KiB
27Wrong answer52ms9484 KiB
28Time limit exceeded1.574s5252 KiB
29Wrong answer78ms21368 KiB
30Wrong answer100ms27552 KiB