Submission #105581

#TimeUsernameProblemLanguageResultExecution timeMemory
105581thiago4532Three Friends (BOI14_friends)C++17
0 / 100
1069 ms9400 KiB
#include <bits/stdc++.h>

using namespace std;

int main() {
	int n;
	cin >> n;
	string str;
	cin >> str;
	if(n%2 == 0){
		cout << "NOT POSSIBLE\n";
		return 0;
	}
	string resp;

	int ct=0;
	for(int i=0;i<n;i++){
		string x;
		for(int j=0;j<n;j++)
			if(j != i) x += str[j];
		int k = x.size();
		string a, b;
		for(int j=0;j<k/2;j++)
			a += x[j];
		for(int j=k/2;j<k;j++)
			b += x[j];
		if(a == b) ct++, resp = a;

		if(ct > 1){
			cout << "NOT UNIQUE\n";
			return 0;
		}
	}
	cout << (ct ? resp : "NOT POSSIBLE") << "\n";
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...