# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
398756 | katwamiaw | Three Friends (BOI14_friends) | C++14 | 1083 ms | 4072 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 a[27] ;
char c[27] ;
vector<int>v ;
vector<string>q ;
set<string>z ;
int n ;
string s ;
void something(int x){
string ans ;
//cout << x << endl ;
for(int i=0 ; i<n/2 ; i++){
//if(i==x) continue ;
int r=i , t=(n/2)+i ;
if(r>=x) r++ ;
if(t>=x) t++ ;
if(s[r]==s[t]){
ans+=s[r] ;
//cout << 8 ;
}
else{
break ;
}
}
if(ans.size()==n/2){
q.push_back(ans) ;
z.insert(ans) ;
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL), cout.tie(NULL);
cin >> n >> s ;
for(int i=0 ; i<n ; i++){
a[(s[i]-'0')-17]++ ;
}
int k=-1 , g=0 ;
for(int i=0 ; i<26 ; i++){
if(a[i]%2){
k=i ;
g++ ;
}
}
if(g>1||k==-1){
cout << "NOT POSSIBLE" ;
return 0 ;
}
for(int i=0 ; i<n ; i++){
if(((s[i]-'0')-17)==k){
v.push_back(i) ;
//cout << s[i] ;
}
}
for(int i=0 ; i<v.size() ; i++){
something(v[i]) ;
}
if(z.size()==0){
cout << "NOT POSSIBLE" ;
}
else if(z.size()>1){
cout << "NOT UNIQUE" ;
}
else{
cout << q[0] ;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |