6277 | 2023-11-11 19:51:55 | aballa | Forgó rulettkerék | cpp11 | Wrong answer 0/100 | 1.577s | 11512 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::string cache;
std::vector<std::string> ids;
int count = 0;
int cachecount = 0;
scanf("%d %d", &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 | Wrong answer | 3ms | 1828 KiB | ||||
2 | Wrong answer | 3ms | 2060 KiB | ||||
subtask2 | 0/20 | ||||||
3 | Wrong answer | 3ms | 2280 KiB | ||||
4 | Wrong answer | 3ms | 2504 KiB | ||||
5 | Wrong answer | 4ms | 2600 KiB | ||||
6 | Wrong answer | 7ms | 2848 KiB | ||||
7 | Wrong answer | 17ms | 3072 KiB | ||||
8 | Wrong answer | 8ms | 2960 KiB | ||||
9 | Wrong answer | 6ms | 2840 KiB | ||||
subtask3 | 0/15 | ||||||
10 | Wrong answer | 97ms | 3416 KiB | ||||
11 | Wrong answer | 79ms | 3488 KiB | ||||
12 | Wrong answer | 823ms | 3584 KiB | ||||
13 | Accepted | 166ms | 3800 KiB | ||||
14 | Wrong answer | 68ms | 3868 KiB | ||||
15 | Time limit exceeded | 1.57s | 2924 KiB | ||||
16 | Time limit exceeded | 1.557s | 2812 KiB | ||||
17 | Time limit exceeded | 1.565s | 3068 KiB | ||||
subtask4 | 0/65 | ||||||
18 | Wrong answer | 1.386s | 5916 KiB | ||||
19 | Time limit exceeded | 1.565s | 3824 KiB | ||||
20 | Time limit exceeded | 1.526s | 3584 KiB | ||||
21 | Time limit exceeded | 1.574s | 3796 KiB | ||||
22 | Time limit exceeded | 1.557s | 3896 KiB | ||||
23 | Wrong answer | 666ms | 5212 KiB | ||||
24 | Time limit exceeded | 1.557s | 3716 KiB | ||||
25 | Time limit exceeded | 1.529s | 3724 KiB | ||||
26 | Time limit exceeded | 1.562s | 11064 KiB | ||||
27 | Time limit exceeded | 1.554s | 4784 KiB | ||||
28 | Time limit exceeded | 1.57s | 5236 KiB | ||||
29 | Time limit exceeded | 1.577s | 11512 KiB | ||||
30 | Time limit exceeded | 1.57s | 11132 KiB |