제출 #139846

#제출 시각아이디문제언어결과실행 시간메모리
139846Saboon세 명의 친구들 (BOI14_friends)C++14
100 / 100
20 ms7192 KiB
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
const int maxn = 2e6 + 10;

int f[maxn];

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	string s;
	cin >> n >> s;
	set<string> allstr;
	if (!(n & 1))
		return cout << "NOT POSSIBLE\n", 0;
	
	int len = n / 2;
	int now = len + 1;
	for (int i = 0; i <= len; i++)
		if (now < n and s[i] == s[now])
			now ++;
	if (now >= n)
		allstr.insert(s.substr(len + 1, len));

	now = 0;
	for (int i = len; i < n; i++)
		if (now < len and s[i] == s[now])
			now ++;
	if (now >= len)
		allstr.insert(s.substr(0, len));

	if (allstr.size() == 0)
		return cout << "NOT POSSIBLE\n", 0;
	if (allstr.size() > 1)
		return cout << "NOT UNIQUE\n", 0;
	cout << *allstr.begin() << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...