제출 #1170516

#제출 시각아이디문제언어결과실행 시간메모리
1170516ZeroCool세 명의 친구들 (BOI14_friends)C++20
100 / 100
10 ms4840 KiB
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define ar array
#define ld long double
#define int long long
#define all(v) v.begin(), v.end()

const int N = 2e5 + 20;
const int K = 469;
const int LOG = 26;
const int INF = 1e12;	
int MOD = 998244353;


bool qry(string s, string t){
	while(s.size() && s.back() == t.back())s.pop_back(), t.pop_back();
	if(s.size())t.pop_back();
	while(s.size() && s.back() == t.back())s.pop_back(), t.pop_back();
	return s.empty();	
}

void orz(){
	int n;
	string s;
	
	cin>>n>>s;
	if(n % 2 == 0){
		cout<<"NOT POSSIBLE";
		return;
	}
	bool x = qry(s.substr(0, n / 2), s.substr(n / 2, n / 2 + 1));
	bool y = qry(s.substr(n / 2 + 1, n / 2), s.substr(0, n / 2 + 1));
	if(!x && !y){
		cout<<"NOT POSSIBLE";
		return;
	}
	if(x && y && s.substr(0, n / 2) != s.substr(n / 2 + 1, n / 2)){
		cout<<"NOT UNIQUE";
		return;
	}
	if(y)cout<<s.substr(n / 2 + 1, n / 2);
	else cout<<s.substr(0, n / 2);
}	
signed main(){ios_base::sync_with_stdio(false);cin.tie(0);
	int t;
	//cin>>t;
	t = 1;
	while(t--)orz();
}
	
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...