6563 | 2023-12-11 18:33:53 | Gervid | Forgó rulettkerék | cpp17 | Wrong answer 0/100 | 1.565s | 5584 KiB |
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int n, m, i, j, k;
cin >> n >> m;
vector<int> count;
vector<string> orderedcodes;
string raw;
for (i = 0; i < n; i++)
{
cin >> raw;
raw += raw;
vector<int> candidates;
char min = 'z';
for (j = 0; j < m; j++)
{
if (raw[j] < min)
{
min = raw[j];
}
}
for (j = 0; j < m; j++)
{
if (raw[j] == min)
{
candidates.push_back(j);
}
}
j = 1;
while (candidates.size() > 1 && j < m)
{
min = 'z';
for (k = 0; k < candidates.size(); k++)
{
if (raw[candidates[k]+j] < min)
{
min = raw[candidates[k] + j];
}
}
for (k = 0; k < candidates.size(); k++)
{
if (raw[candidates[k]+j] > min)
{
candidates.erase(candidates.begin()+k);
if (candidates.size() == 1)
{
break;
}
}
}
j++;
}
string ordered;
for (j = 0; j < m; j++)
{
ordered.push_back(raw[candidates[0] + j]);
}
for (j = 0; j < orderedcodes.size(); j++)
{
if (ordered == orderedcodes[j])
{
count[j]++;
break;
}
}
if (j == orderedcodes.size())
{
orderedcodes.push_back(ordered);
count.push_back(1);
}
}
int out = 0;
for (i = 0; i < count.size(); i++)
{
out += (count[i] * (count[i] - 1)) >> 1;
}
cout << out;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1808 KiB | ||||
2 | Accepted | 3ms | 2088 KiB | ||||
subtask2 | 0/20 | ||||||
3 | Accepted | 3ms | 2212 KiB | ||||
4 | Wrong answer | 3ms | 2300 KiB | ||||
5 | Wrong answer | 3ms | 2656 KiB | ||||
6 | Wrong answer | 4ms | 2748 KiB | ||||
7 | Accepted | 4ms | 2932 KiB | ||||
8 | Wrong answer | 4ms | 3156 KiB | ||||
9 | Wrong answer | 4ms | 3224 KiB | ||||
subtask3 | 0/15 | ||||||
10 | Wrong answer | 48ms | 3116 KiB | ||||
11 | Wrong answer | 68ms | 3192 KiB | ||||
12 | Wrong answer | 59ms | 3584 KiB | ||||
13 | Wrong answer | 48ms | 3464 KiB | ||||
14 | Wrong answer | 50ms | 3392 KiB | ||||
15 | Wrong answer | 54ms | 3896 KiB | ||||
16 | Accepted | 52ms | 4260 KiB | ||||
17 | Wrong answer | 50ms | 3828 KiB | ||||
subtask4 | 0/65 | ||||||
18 | Wrong answer | 108ms | 3540 KiB | ||||
19 | Wrong answer | 101ms | 3540 KiB | ||||
20 | Wrong answer | 759ms | 4332 KiB | ||||
21 | Wrong answer | 233ms | 4308 KiB | ||||
22 | Wrong answer | 128ms | 3940 KiB | ||||
23 | Wrong answer | 377ms | 3756 KiB | ||||
24 | Wrong answer | 130ms | 4536 KiB | ||||
25 | Wrong answer | 1.126s | 4516 KiB | ||||
26 | Wrong answer | 177ms | 3980 KiB | ||||
27 | Wrong answer | 168ms | 4572 KiB | ||||
28 | Time limit exceeded | 1.562s | 5584 KiB | ||||
29 | Wrong answer | 402ms | 4996 KiB | ||||
30 | Time limit exceeded | 1.565s | 4160 KiB |