Submission #44307

#TimeUsernameProblemLanguageResultExecution timeMemory
44307dhruvsomani세 명의 친구들 (BOI14_friends)C++14
0 / 100
31 ms5580 KiB
#include <iostream>
#include <iomanip>
#include <fstream>

#include <cmath>
#include <string>

#include <algorithm>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

int n;
string s, temp;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	cin >> n;
	cin >> s;

	if (n%2 == 0) {
		cout << "NOT POSSIBLE\n";
		return 0;
	}

	set<string> count;

	int one, two;
	bool done, poss;

	one = 0;
	two = n/2 + 1;
	done = false;
	poss = true;
	temp = "";

	while(two < n) {
		if (s[one] != s[two]) {
			if (!done) {
				done = true;
				one++;
			}
			else {
				poss = false;
				break;
			}
		}
		else {
			temp += s[one];
			one++;
			two++;
		}
	}
	if (poss) count.insert(temp);

	one = 0;
	two = n/2;
	done = false;
	poss = true;
	temp = "";

	while(two < n) {
		if (s[one] != s[two]) {
			if (!done) {
				done = true;
				two++;
			}
			else {
				poss = false;
				break;
			}
		}
		else {
			temp += s[one];
			one++;
			two++;
		}
	}
	
	if (poss) count.insert(temp);

	if (count.size() == 0) cout << "NOT POSSIBLE\n";
	else if (count.size() == 1) cout << *(count.begin()) << endl;
	else cout << "NOT UNIQUE\n";

	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...