6282 | 2023-11-12 13:35:39 | aballa | Forgó rulettkerék | cpp17 | Time limit exceeded 20/100 | 1.578s | 12552 KiB |
#include <bits/stdc++.h>
int n, m;
bool similar(std::string a, std::string b) {
const std::string c = a+a;
std::string str;
for(int i = 0; i < m; i++) {
str = std::string(&c[i], &c[i+m]);
if (str == b)
{
return 1;
}
}
return 0;
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::string cache;
std::vector<std::string> ids;
int count = 0;
int cachecount = 0;
std::cin >> n >> m;
for(int i = 0; i < n; i++) {
std::cin >> cache;
ids.push_back(cache);
}
for (int i = 0; i < n; i++) {
if (ids[i] == "#") {continue;}
cachecount = 0;
for (int j = 0; j < n-i-1; j++) {
if (ids[n-j-1] == "#") {continue;}
if(similar(ids[i], ids[n-j-1])) {
cachecount++;
ids[n-j-1] = "#";
}
}
count = count + (cachecount*(cachecount+1))/2;
}
std::cout << count;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1828 KiB | ||||
2 | Accepted | 3ms | 2060 KiB | ||||
subtask2 | 20/20 | ||||||
3 | Accepted | 3ms | 2280 KiB | ||||
4 | Accepted | 3ms | 2660 KiB | ||||
5 | Accepted | 3ms | 2764 KiB | ||||
6 | Accepted | 6ms | 2832 KiB | ||||
7 | Accepted | 19ms | 2916 KiB | ||||
8 | Accepted | 6ms | 3192 KiB | ||||
9 | Accepted | 7ms | 3388 KiB | ||||
subtask3 | 0/15 | ||||||
10 | Accepted | 85ms | 4052 KiB | ||||
11 | Accepted | 57ms | 4332 KiB | ||||
12 | Accepted | 846ms | 4408 KiB | ||||
13 | Accepted | 159ms | 4612 KiB | ||||
14 | Accepted | 54ms | 4740 KiB | ||||
15 | Time limit exceeded | 1.554s | 3680 KiB | ||||
16 | Time limit exceeded | 1.549s | 3660 KiB | ||||
17 | Time limit exceeded | 1.557s | 3592 KiB | ||||
subtask4 | 0/65 | ||||||
18 | Accepted | 1.253s | 6196 KiB | ||||
19 | Time limit exceeded | 1.572s | 4464 KiB | ||||
20 | Time limit exceeded | 1.557s | 4296 KiB | ||||
21 | Time limit exceeded | 1.569s | 4548 KiB | ||||
22 | Time limit exceeded | 1.569s | 4640 KiB | ||||
23 | Accepted | 666ms | 6260 KiB | ||||
24 | Time limit exceeded | 1.562s | 4876 KiB | ||||
25 | Time limit exceeded | 1.554s | 5100 KiB | ||||
26 | Time limit exceeded | 1.575s | 12508 KiB | ||||
27 | Time limit exceeded | 1.562s | 6152 KiB | ||||
28 | Time limit exceeded | 1.575s | 6520 KiB | ||||
29 | Time limit exceeded | 1.565s | 12552 KiB | ||||
30 | Time limit exceeded | 1.578s | 12324 KiB |