Submission #1126405

#TimeUsernameProblemLanguageResultExecution timeMemory
1126405AgageldiThree Friends (BOI14_friends)C++20
0 / 100
1096 ms5348 KiB
/*
ID: agageld1
LANG: C++17
TASK:
*/
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define N 400005
#define ff first
#define ss second
#define pb push_back
#define sz(s) (int)s.size()
#define rep(c, a, b) for(c = a; c <= b; c++)

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll n, t, a[N];
string s, g;
vector <string> v, h;

int main () {
	ios::sync_with_stdio(0);cin.tie(0);
	cin >> n >> s;
	if(n%2 == 0 || n == 1) {
		cout << "NOT POSSIBLE";
		return 0;
	}
	for(int i = 0; i < n; i++) {
		g = "";
		v.clear();
		for(int j = 0;j<n;j++) {
			if(j == i) continue;
			g += s[j];
			if(sz(g) == (n / 2)) {
				v.pb(g);
				g = "";
			}
		}
		assert(sz(v[0]) == sz(v[1]));
		if(v[0] == v[1]) {
			h.pb(v[0]);
		}
	}
	if(!sz(h)) {
		cout << "NOT POSSIBLE";
		return 0;
	}
	if(sz(h) > 1) {
		cout << "NOT UNIQUE";
		return 0;
	}
	cout << h[0];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...