# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
743313 | irmuun | Three Friends (BOI14_friends) | C++17 | 13 ms | 7324 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,string t){
int n=s.size();
int cur=0;
for(int i=0;i<s.size();i++){
if(cur<n-1&&s[i]==t[cur]){
cur++;
}
}
return (cur==n-1);
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n;
cin>>n;
string s;
cin>>s;
if(n%2==0){
cout<<"NOT POSSIBLE";
return 0;
}
set<string>st;
if(check(s.substr(n/2,n/2+1),s.substr(0,n/2))==true){
st.insert(s.substr(0,n/2));
}
if(check(s.substr(0,n/2+1),s.substr(n/2+1,n/2))==true){
st.insert(s.substr(n/2+1,n/2));
}
if(st.size()==0){
cout<<"NOT POSSIBLE";
}
else if(st.size()==1){
cout<<*st.begin();
}
else{
cout<<"NOT UNIQUE";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |