# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
943338 | Darren0724 | Three Friends (BOI14_friends) | C++17 | 8 ms | 7680 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;
#define LCBorz ios_base::sync_with_stdio(false); cin.tie(0);
#define all(x) x.begin(), x.end()
#define endl '\n'
const int N=200005;
const int INF=1e9;
string cmp(string a,string b){
if(a.size()>b.size())swap(a,b);
int bad=0;
int j=0;
int n=a.size();
for(int i=0;i<n;i++){
while(j<b.size()&&a[i]!=b[j]){
bad++;
j++;
}
j++;
}
return (bad<=1?a:"");
}
int32_t main() {
LCBorz;
int n;cin>>n;
string s;cin>>s;
string a=cmp(s.substr(0,n/2),s.substr(n/2,n-n/2));
string b=cmp(s.substr(0,n/2+1),s.substr(n/2+1,n-n/2));
if(n%2==0||(a.size()==0&&b.size()==0)){
cout<<"NOT POSSIBLE"<<endl;
return 0;
}
if(a.size()!=0&&b.size()!=0&&a!=b){
cout<<"NOT UNIQUE"<<endl;
return 0;
}
cout<<(a.size()?a:b)<<endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |