6291 | 2023-11-13 13:54:29 | aballa | Forgó rulettkerék | cpp17 | Time limit exceeded 35/100 | 1.57s | 11936 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++) {
count += (ids[i] == ids[n-j-1]);
}
}
std::cout << count;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1824 KiB | ||||
2 | Accepted | 3ms | 2064 KiB | ||||
subtask2 | 20/20 | ||||||
3 | Accepted | 3ms | 2296 KiB | ||||
4 | Accepted | 3ms | 2512 KiB | ||||
5 | Accepted | 3ms | 2736 KiB | ||||
6 | Accepted | 3ms | 2828 KiB | ||||
7 | Accepted | 3ms | 2956 KiB | ||||
8 | Accepted | 3ms | 3020 KiB | ||||
9 | Accepted | 3ms | 3364 KiB | ||||
subtask3 | 15/15 | ||||||
10 | Accepted | 19ms | 3884 KiB | ||||
11 | Accepted | 26ms | 4068 KiB | ||||
12 | Accepted | 23ms | 3968 KiB | ||||
13 | Accepted | 18ms | 4052 KiB | ||||
14 | Accepted | 25ms | 4260 KiB | ||||
15 | Accepted | 24ms | 4356 KiB | ||||
16 | Accepted | 24ms | 4480 KiB | ||||
17 | Accepted | 24ms | 4368 KiB | ||||
subtask4 | 0/65 | ||||||
18 | Accepted | 119ms | 5932 KiB | ||||
19 | Accepted | 122ms | 5796 KiB | ||||
20 | Accepted | 200ms | 5452 KiB | ||||
21 | Accepted | 70ms | 5756 KiB | ||||
22 | Accepted | 90ms | 6016 KiB | ||||
23 | Accepted | 120ms | 5748 KiB | ||||
24 | Accepted | 79ms | 5760 KiB | ||||
25 | Accepted | 907ms | 6136 KiB | ||||
26 | Time limit exceeded | 1.554s | 11568 KiB | ||||
27 | Accepted | 1.113s | 8044 KiB | ||||
28 | Time limit exceeded | 1.559s | 5036 KiB | ||||
29 | Time limit exceeded | 1.57s | 11936 KiB | ||||
30 | Time limit exceeded | 1.559s | 11880 KiB |