# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
938196 | Sir_Ahmed_Imran | Three Friends (BOI14_friends) | C++17 | 27 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.
///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define append push_back
#define add insert
#define nl "\n"
#define ff first
#define ss second
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL)
#define N 100001
void solve(){
int n,m,o,p,q,r;
string s,t;
cin>>n>>s;
s.append('.');
if(n%2==0){
cout<<"NOT POSSIBLE";
return;
}
m=n/2;
t="";
for(int i=0;i<m;i++){
if(s[i]!=s[i+m+1])
break;
t.append(s[i]);
}
if(t.size()==m){
cout<<t;
return;
}
o=p=q=0;
for(int i=m;i<n;i++)
if(s[i]==s[o]) o++;
if(o>=m) p=1;
o=m+1;
for(int i=0;i<=m;i++)
if(s[i]==s[o]) o++;
if(o>=n) q=1;
if(p && q) cout<<"NOT UNIQUE";
else if(p){
for(int i=0;i<m;i++)
cout<<s[i];
}
else if(q){
for(int i=m+1;i<n;i++)
cout<<s[i];
}
else cout<<"NOT POSSIBLE";
}
int main(){
L0TA;
solve();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |