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 <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
string s, a = "", b = "", c = "", d = "", answer1 = "", answer2 = "";
cin >> s;
if (n % 2 == 0){cout << "NOT POSSIBLE"; return 0;}
for (int i = 0; i < n; i++){
if (i < n/2) a += s[i], c += s[i];
else if (i == n/2) b += s[i], c += s[i];
else b += s[i], d += s[i];
}
string x = "", y = "";
int add = 0;
for (int i = 0; i < n/2; i++){
if (a[i] == b[i+add]) x += a[i], y += b[i+add];
else x += a[i], y += b[i+1], add = 1;
}
if (x == y) answer1 = x;
x = "", y = "";
add = 0;
for (int i = 0; i < n/2; i++){
if (d[i] == c[i+add]) x += d[i], y += c[i+add];
else x += d[i], y += c[i+1], add = 1;
}
if (x == y) answer2 = x;
//cout << "answer2: " << answer2 << "\n";
if (answer1.size() && answer2.size() && answer1 != answer2) cout << "NOT UNIQUE";
else if (!answer1.size() && !answer2.size()) cout << "NOT POSSIBLE";
else if (answer1.size()) cout << answer1;
else cout << answer2;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |