This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |