Submission #113592

#TimeUsernameProblemLanguageResultExecution timeMemory
113592derpwaffle21Three Friends (BOI14_friends)C++14
0 / 100
1081 ms8512 KiB
#include <iostream>
#include <cstring>

using namespace std;

bool isSame(string s1, string s2)
{
	for (int i = 0; i < signed(s1.size()); i++)
	{
		if (s1[i] != s2[i])
			return false;
	}

	return true;
}

int main()
{
	int n;

	cin >> n;

	/*
	while (true)
	{
		string t;

		for (int i = 0; i < n - 1; i++)
			t += char((rand() % 26) + 65);

		cout << t << endl;
		cout << t.substr(0, int((n - 1) / 2)) << endl;
		cout << t.substr(int((n - 1) / 2), n - 1) << endl;

		cin >> t;
	}*/

	if (n % 2 == 0)
	{
		cout << "NOT POSSIBLE" << endl;
		return 0;
	}

	string s;
	string res;
	int resNum = 0;

	cin >> s;

	for (int i = 0; i < n; i++)
	{
		string t = s;

		for (int j = i; j < n; j++)
		{
			t[j] = t[j + 1];
		}

		/*
		for (int j = 0; j < n - 1; j++)
			cout << t[j];

		cout << endl;*/
		/*
		cout << t.substr(0, int((n - 1) / 2)) << endl;
		cout << t.substr(int((n - 1) / 2), n - 1) << endl;*/

		if (isSame(t.substr(0, int((n - 1) / 2)), t.substr(int((n - 1) / 2), n - 1)))
		{
			resNum++;
			res = t.substr(0, int((n - 1) / 2));
		}
	}

	if (resNum == 0)
		cout << "NOT POSSIBLE" << endl;
	else if (resNum > 1)
		cout << "NOT UNIQUE" << endl;
	else
		cout << res << endl;

	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...