제출 #742004

#제출 시각아이디문제언어결과실행 시간메모리
742004MODDIThree Friends (BOI14_friends)C++14
0 / 100
50 ms8084 KiB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
int n;
string str;
int main(){
	cin>>n>>str;
	string one, two;
	int i, t;
	for(i = 0; i < n/2; i++)
		if(str[i] != str[i+n/2])	break;
	t = i;
	for(int i = n/2-1; i>= 0; i--)
		if(str[i] != str[i+n/2+1])	break;
	
	int flag;
	if(t > 1)	flag = 1;
	else flag = 0;
	for(i = 0; i < n/2+1; i++)
		if(str[i] != str[i+n/2+1])	break;
	t = i;
	for(int i = n/2; i >= 0; i--)
		if(str[i] != str[i+n/2])	break;
	if(t >= i){
		if(flag){
			for(i = 0; i < n/2; i++)
				if(str[i] != str[i+n/2+1])	break;
				
			if(i == n/2){
				string out;
				for(i = 0; i < n/2; i++) out.pb(str[i]);
				
				cout<<out<<endl;
			}
			else
				cout<<"NOT UNIQUE"<<endl;
		}
		else{
			string out;
			for(i = 0; i <n/2; i++)	out.pb(str[i+n/2+1]);
			cout<<out<<endl;
		}
	}
	else{
		if(flag){
			string out;
				for(i = 0; i < n/2; i++) out.pb(str[i]);
				
				cout<<out<<endl;
		}
		else
			cout<<"NOT POSSIBLE"<<endl;
	}
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...