# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
743294 | irmuun | Three Friends (BOI14_friends) | C++17 | 1063 ms | 8500 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 pb push_back
#define ll long long
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
bool check(string s){
if(s.size()%2==1){
return false;
}
int n=s.size();
for(int i=0;i<s.size()/2;i++){
if(s[i]!=s[i+n/2]){
return false;
}
}
return true;
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n;
cin>>n;
string s;
cin>>s;
vector<int>cnt(26);
int ans=0;
string x="";
for(int i=0;i<n;i++){
string t=s.substr(0,i)+s.substr(i+1,n-i-1);
if(check(t)==true){
if(x==""){
x=t;
ans=1;
}
else if(x!=t){
ans=2;
}
}
}
if(ans==0){
cout<<"NOT POSSIBLE";
}
else if(ans==1){
cout<<x.substr(0,n/2);
}
else{
cout<<"NOT UNIQUE";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |