제출 #657098

#제출 시각아이디문제언어결과실행 시간메모리
657098Juan세 명의 친구들 (BOI14_friends)C++17
0 / 100
4 ms468 KiB
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 5;

char v[maxn];

int main(){
	int n; cin >> n;
	for(int i = 1; i <= n; i++) cin >> v[i];

	int okcnt = 0;
	string ans = "";
	for(int i = 1; i <= n; i++){
		bool ok = true;
		for(int j = 1; j <= n/2+(i<=n/2); j++){
			if(j==i) continue;
			if(v[j]!=v[j+(n/2)+(i<=j+n/2)-(i<j)]) {ok = false; break;}
		}
		if(ok){
			for(int j = 1; j <= n/2+(i<=n/2); j++){
				if(j==i) continue;
				ans+=v[j];
			}
			if(okcnt) {cout << "NOT UNIQUE\n"; return 0;}
			okcnt++;
		}
	}

	if(okcnt==0) cout << "NOT POSSIBLE\n";
	else cout << ans << '\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...