제출 #1342082

#제출 시각아이디문제언어결과실행 시간메모리
1342082Minbaev세 명의 친구들 (BOI14_friends)C++20
35 / 100
1094 ms6312 KiB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const ll mod = 1e9 + 7;

ll n,m,k;

void solve(){
	
	cin >> n;
	string str;
	cin >> str;
	
	if(n % 2 == 0){
		cout << "NOT POSSIBLE\n";
		return;
	}
	
	set<string>st;
	string ans;
	
	for(int i = 0;i<str.size();i++){
		string a = "", b = "";
		int j = 0;
		while(a.size() < n / 2){
			if(j == i){
				j += 1;
				continue;
			}
			a += str[j++];
		}
		while(b.size() < n / 2){
			if(j == i){
				j += 1;
				continue;
			}
			b += str[j++];
		}
		
		if(a == b){
			st.insert(a);
			ans = a;
		}
	}
	
	int cnt = st.size();
	
	if(cnt == 0){
		cout << "NOT POSSIBLE\n";
		return;
	}
	
	if(cnt > 1){
		cout << "NOT UNIQUE\n";
		return;
	}
	
	cout << ans << "\n";
	
	
	
}
/*
7
ABXCABC
*/
 signed main()
{
//  freopen("seq.in", "r", stdin);
//  freopen("seq.out", "w", stdout);
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    int tt=1;//cin >> tt;
    while(tt--)solve();    

}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...