Submission #657106

#TimeUsernameProblemLanguageResultExecution timeMemory
657106Juan세 명의 친구들 (BOI14_friends)C++17
35 / 100
14 ms340 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){
			string tstr;
			for(int j = 1; j <= n/2+(i<=n/2); j++){
				if(j==i) continue;
				tstr+=v[j];
			}
			if(okcnt && ans!=tstr) {cout << "NOT UNIQUE\n"; return 0;}
			ans = tstr;
			okcnt++;
		}
	}

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