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