6293 | 2023-11-13 15:50:35 | aballa | Forgó rulettkerék | cpp17 | Wrong answer 0/100 | 1.559s | 27596 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;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 4ms | 1972 KiB | ||||
2 | Accepted | 3ms | 2180 KiB | ||||
subtask2 | 0/20 | ||||||
3 | Accepted | 3ms | 2252 KiB | ||||
4 | Accepted | 3ms | 2612 KiB | ||||
5 | Wrong answer | 3ms | 2676 KiB | ||||
6 | Wrong answer | 3ms | 3032 KiB | ||||
7 | Accepted | 3ms | 3408 KiB | ||||
8 | Wrong answer | 3ms | 3320 KiB | ||||
9 | Wrong answer | 3ms | 3472 KiB | ||||
subtask3 | 0/15 | ||||||
10 | Wrong answer | 17ms | 4376 KiB | ||||
11 | Wrong answer | 21ms | 4536 KiB | ||||
12 | Wrong answer | 20ms | 4696 KiB | ||||
13 | Wrong answer | 17ms | 4356 KiB | ||||
14 | Accepted | 20ms | 4544 KiB | ||||
15 | Accepted | 23ms | 5228 KiB | ||||
16 | Accepted | 23ms | 5472 KiB | ||||
17 | Accepted | 21ms | 5408 KiB | ||||
subtask4 | 0/65 | ||||||
18 | Wrong answer | 45ms | 6416 KiB | ||||
19 | Wrong answer | 43ms | 6552 KiB | ||||
20 | Wrong answer | 200ms | 6660 KiB | ||||
21 | Wrong answer | 65ms | 7136 KiB | ||||
22 | Wrong answer | 50ms | 7100 KiB | ||||
23 | Accepted | 119ms | 6484 KiB | ||||
24 | Wrong answer | 48ms | 7516 KiB | ||||
25 | Wrong answer | 902ms | 6976 KiB | ||||
26 | Wrong answer | 74ms | 21224 KiB | ||||
27 | Wrong answer | 54ms | 9572 KiB | ||||
28 | Time limit exceeded | 1.559s | 5468 KiB | ||||
29 | Accepted | 79ms | 21176 KiB | ||||
30 | Wrong answer | 104ms | 27596 KiB |