6290 | 2023-11-13 13:52:08 | aballa | Forgó rulettkerék | cpp17 | Time limit exceeded 35/100 | 1.565s | 12676 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;
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::string cache;
std::vector<std::string> ids;
std::cin >> n >> m;
for(int i = 0; i < n; i++) {
std::cin >> cache;
ids.push_back(tagid(cache));
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n-i-1; j++) {
if(ids[i] == ids[n-j-1]) count++;
}
}
std::cout << count;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1832 KiB | ||||
2 | Accepted | 3ms | 2056 KiB | ||||
subtask2 | 20/20 | ||||||
3 | Accepted | 3ms | 2272 KiB | ||||
4 | Accepted | 3ms | 2480 KiB | ||||
5 | Accepted | 3ms | 2536 KiB | ||||
6 | Accepted | 3ms | 2800 KiB | ||||
7 | Accepted | 3ms | 3016 KiB | ||||
8 | Accepted | 3ms | 3248 KiB | ||||
9 | Accepted | 3ms | 3536 KiB | ||||
subtask3 | 15/15 | ||||||
10 | Accepted | 18ms | 4444 KiB | ||||
11 | Accepted | 25ms | 4456 KiB | ||||
12 | Accepted | 21ms | 4540 KiB | ||||
13 | Accepted | 18ms | 4360 KiB | ||||
14 | Accepted | 24ms | 4572 KiB | ||||
15 | Accepted | 24ms | 4700 KiB | ||||
16 | Accepted | 23ms | 4696 KiB | ||||
17 | Accepted | 23ms | 4888 KiB | ||||
subtask4 | 0/65 | ||||||
18 | Accepted | 123ms | 6440 KiB | ||||
19 | Accepted | 126ms | 6408 KiB | ||||
20 | Accepted | 199ms | 6208 KiB | ||||
21 | Accepted | 68ms | 6556 KiB | ||||
22 | Accepted | 90ms | 6500 KiB | ||||
23 | Accepted | 120ms | 6548 KiB | ||||
24 | Accepted | 79ms | 6716 KiB | ||||
25 | Accepted | 904ms | 6940 KiB | ||||
26 | Time limit exceeded | 1.565s | 12244 KiB | ||||
27 | Accepted | 1.151s | 8572 KiB | ||||
28 | Time limit exceeded | 1.56s | 5236 KiB | ||||
29 | Time limit exceeded | 1.565s | 12308 KiB | ||||
30 | Time limit exceeded | 1.557s | 12676 KiB |