# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1200561 | amanthaband | Three Friends (BOI14_friends) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
string u;
cin >> n >> u;
set<string> ans;
for (int i = 0; i < n; i++) {
string t = u.substr(0, i) + u.substr(i + 1);
if (t.size() % 2 != 0) continue;
int m = t.size() / 2;
string a = t.substr(0, m);
string b = t.substr(m);
if (a == b) ans.insert(a);
}
if (ans.size() == 0) cout << "NOT POSSIBLE\n";
else if (ans.size() > 1) cout << "NOT UNIQUE\n";
else cout << *ans.begin() << '\n';
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
string u;
cin >> n >> u;
set<string> ans;
for (int i = 0; i < n; i++) {
string t = u.substr(0, i) + u.substr(i + 1);
if (t.size() % 2 != 0) continue;
int m = t.size() / 2;
string a = t.substr(0, m);
string b = t.substr(m);
if (a == b) ans.insert(a);
}
if (ans.size() == 0) cout << "NOT POSSIBLE\n";
else if (ans.size() > 1) cout << "NOT UNIQUE\n";
else cout << *ans.begin() << '\n';
return 0;
}