6100 | 2023-10-29 19:07:37 | MCDave | Forgó rulettkerék | cpp17 | Time limit exceeded 35/100 | 1.557s | 14452 KiB |
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
using namespace std;
string shiftToSort(string input) {
int n = input.length();
string sortedStr = input;
for (int shift = 1; shift < n; shift++) {
string shiftedStr = input.substr(shift) + input.substr(0, shift);
sortedStr = min(sortedStr, shiftedStr);
}
return sortedStr;
}
int main() {
int n, m;
cin >> n >> m;
unordered_map<string, int> sortedCount;
for (int i = 0; i < n; i++) {
string input;
cin >> input;
string sortedStr = shiftToSort(input);
sortedCount[sortedStr]++;
}
long long out = 0;
for (const auto& entry : sortedCount) {
int count = entry.second;
out += (count * 1LL * (count - 1)) / 2;
}
cout << out;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1708 KiB | ||||
2 | Accepted | 3ms | 1932 KiB | ||||
subtask2 | 20/20 | ||||||
3 | Accepted | 3ms | 2144 KiB | ||||
4 | Accepted | 3ms | 2224 KiB | ||||
5 | Accepted | 3ms | 2480 KiB | ||||
6 | Accepted | 4ms | 2596 KiB | ||||
7 | Accepted | 4ms | 2828 KiB | ||||
8 | Accepted | 4ms | 2908 KiB | ||||
9 | Accepted | 4ms | 3108 KiB | ||||
subtask3 | 15/15 | ||||||
10 | Accepted | 54ms | 3244 KiB | ||||
11 | Accepted | 68ms | 3400 KiB | ||||
12 | Accepted | 63ms | 3496 KiB | ||||
13 | Accepted | 52ms | 3852 KiB | ||||
14 | Accepted | 61ms | 3888 KiB | ||||
15 | Accepted | 68ms | 4468 KiB | ||||
16 | Accepted | 68ms | 4984 KiB | ||||
17 | Accepted | 68ms | 4760 KiB | ||||
subtask4 | 0/65 | ||||||
18 | Accepted | 143ms | 4260 KiB | ||||
19 | Accepted | 135ms | 4296 KiB | ||||
20 | Accepted | 598ms | 5036 KiB | ||||
21 | Accepted | 210ms | 4872 KiB | ||||
22 | Accepted | 162ms | 4700 KiB | ||||
23 | Accepted | 312ms | 4568 KiB | ||||
24 | Accepted | 148ms | 5268 KiB | ||||
25 | Time limit exceeded | 1.557s | 3768 KiB | ||||
26 | Accepted | 118ms | 4608 KiB | ||||
27 | Accepted | 150ms | 5540 KiB | ||||
28 | Time limit exceeded | 1.557s | 4792 KiB | ||||
29 | Accepted | 119ms | 6292 KiB | ||||
30 | Accepted | 137ms | 14452 KiB |