60822023-10-29 16:43:54MCDaveForgó rulettkerékcpp17Time limit exceeded 20/1001.58s19124 KiB
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <queue>

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;

	vector<string> cimkek(n);

	for (int i = 0; i < n; i++)
	{
		cin >> cimkek[i];
	}
	int index=0;
	set<int> been;
	vector<int> count;
	while (index != n and been.size() != n)
	{
		if (!been.count(index))
		{
			int temp1=1;
			for (int shift = 0; shift < m; shift++)
			{
				string current = cimkek[index];
				for (int i = 0; i < m; i++) {
					int newIndex = (i - shift + m) % m;
					current[newIndex] = cimkek[index][i];
				}
				for (int str = index+1; str < n; str++)
				{
					if (!been.count(str) and cimkek[str] == current)
					{
						been.insert(str);
						temp1++;
					}
				}
			}
			if (temp1>1)
			{
				count.push_back(temp1);
			}
			temp1 = 1;
		}
		index++;
	}

	int out = 0;

	for (int i = 0; i < count.size(); i++)
	{
		out += (count[i] * (count[i] - 1)) / 2;
	}
	cout << out;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1816 KiB
2Accepted3ms2060 KiB
subtask220/20
3Accepted3ms2244 KiB
4Accepted3ms2488 KiB
5Accepted3ms2672 KiB
6Accepted4ms2744 KiB
7Accepted12ms2872 KiB
8Accepted4ms3084 KiB
9Accepted6ms3308 KiB
subtask30/15
10Accepted279ms4500 KiB
11Accepted412ms4500 KiB
12Accepted948ms4512 KiB
13Accepted402ms4736 KiB
14Accepted305ms4828 KiB
15Time limit exceeded1.565s3864 KiB
16Time limit exceeded1.552s3788 KiB
17Time limit exceeded1.58s4040 KiB
subtask40/65
18Time limit exceeded1.565s5208 KiB
19Time limit exceeded1.565s5100 KiB
20Time limit exceeded1.57s4872 KiB
21Time limit exceeded1.549s5452 KiB
22Time limit exceeded1.526s5176 KiB
23Accepted828ms6724 KiB
24Time limit exceeded1.565s5508 KiB
25Time limit exceeded1.57s5292 KiB
26Time limit exceeded1.554s12880 KiB
27Time limit exceeded1.562s6480 KiB
28Time limit exceeded1.508s5464 KiB
29Time limit exceeded1.57s19124 KiB
30Time limit exceeded1.57s13192 KiB