# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
996277 | SuPythony | Three Friends (BOI14_friends) | C++17 | 39 ms | 11068 KiB |
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;
typedef long long ll;
int main() {
int n; cin>>n;
string s; cin>>s;
if (n%2==0) cout<<"NOT POSSIBLE";
else {
string l=s.substr(0,(n-1)/2), r=s.substr((n-1)/2+1,(n-1)/2);
string lc=s.substr((n-1)/2,(n-1)/2+1), rc=s.substr(0,(n-1)/2+1);
vector<string> ans;
int ind=0;
bool wrong=false;
bool pos=true;
for (char i: lc) {
if (i!=l[ind]) {
if (!wrong) {
wrong=true;
continue;
} else {
pos=false;
break;
}
}
ind++;
if (ind==lc.size()) break;
}
if (pos) ans.push_back(l);
ind=0;
wrong=false;
pos=true;
for (char i: rc) {
if (i!=r[ind]) {
if (!wrong) {
wrong=true;
continue;
} else {
pos=false;
break;
}
}
ind++;
if (ind==rc.size()) break;
}
if (pos) ans.push_back(r);
if (ans.empty()) cout<<"NOT POSSIBLE";
else if (ans.size()>1&&ans[0]!=ans[1]) cout<<"NOT UNIQUE";
else cout<<ans[0];
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |