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;
string s,t;
int l,r,i,p,n,f,g;
bool check() {
p = 0;
for(i = l; i <= r; i++) {
if(p != t.size() && t[p] == s[i]) {
p++;
}
}
return (p == t.size());
}
int32_t main() {
cin >> n;
cin >> s;
if(n % 2 == 0) {
cout << "NOT POSSIBLE\n";
return 0;
}
t = s.substr(0, n / 2);
l = n / 2;
r = n - 1;
f = check();
t = s.substr(n - n / 2, n / 2);
l = 0;
r = n / 2;
g = check();
if(!f && !g) {
cout << "NOT POSSIBLE\n";
}
else if(f && g && s.substr(0, n / 2) != s.substr(n - n / 2, n / 2)) {
cout << "NOT UNIQUE\n";
}
else if(f) {
cout << s.substr(0, n / 2) << "\n";
}
else {
cout << s.substr(n - n / 2, n / 2) << "\n";
}
}
Compilation message (stderr)
friends.cpp: In function 'bool check()':
friends.cpp:9:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
9 | if(p != t.size() && t[p] == s[i]) {
| ~~^~~~~~~~~~~
friends.cpp:13:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
13 | return (p == t.size());
| ~~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |