# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
398943 | katwamiaw | Three Friends (BOI14_friends) | C++14 | 73 ms | 14932 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 ;
//it ain't much but it's honest work
int n ;
set<string>r ;
string ans , s ;
void ihope( string a , string b){
string c ;
//cout << a << ' ' << b << endl ;
int ac=0 , bc=0 ;
for(int i=0 ; i<n/2 ; i++){
if(a[i]!=b[bc]){
bc++ ;
}
if(a[i]==b[bc]){
c+=a[i] ;
}
bc++ ;
if(bc>n/2) break ;
}
//cout << c << endl ;
if(c.size()==n/2){
ans=c ;
r.insert(ans) ;
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL), cout.tie(NULL);
cin >> n >> s ;
if(n%2==0){
cout << "NOT POSSIBLE" ;
return 0 ;
}
string a1 , b1 ;
for(int i=0 ; i<n/2 ; i++){
a1+=s[i] ;
}
for(int i=n/2 ; i<n ; i++){
b1+=s[i] ;
}
ihope(a1 , b1) ;
string a2 , b2 ;
for(int i=0 ; i<n/2+1 ; i++){
a2+=s[i] ;
}
for(int i=n/2+1 ; i<n ; i++){
b2+=s[i] ;
}
ihope(b2 , a2) ;
string a3 , b3 ;
for(int i=0 ; i<n/2 ; i++){
a3+=s[i] ;
}
for(int i=n/2+1 ; i<n ; i++){
b3+=s[i] ;
}
ihope(a3,b3) ;
if(r.size()>1){
cout << "NOT UNIQUE" ;
}
else if(r.size()==0){
cout << "NOT POSSIBLE" ;
}
else{
cout << ans ;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |