# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
484281 | MohamedAhmed04 | Three Friends (BOI14_friends) | C++14 | 8 ms | 6256 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 ;
const int MAX = 2e6 + 10 ;
int arr[MAX] ;
int n ;
string s ;
bool check(string s2 , int l , int r)
{
int idx = 0 ;
int rem = 1 ;
for(int i = l ; i <= r && idx < s2.size() ; ++i)
{
if(s[i] == s2[idx])
++idx ;
else
rem-- ;
}
return (idx == s2.size() && rem >= 0) ;
}
int main()
{
ios_base::sync_with_stdio(0) ;
cin.tie(0) ;
cin>>n ;
cin>>s ;
bool flag1 = check(s.substr(0 , n/2) , n/2 , n-1) ;
bool flag2 = check(s.substr(n-n/2 , n/2) , 0 , n/2) ;
if(!flag1 && !flag2)
cout<<"NOT POSSIBLE\n" ;
else if(flag1 && flag2 && s.substr(0 , n/2) != s.substr(n-n/2 , n/2))
cout<<"NOT UNIQUE\n" ;
else if(flag1)
cout<<s.substr(0 , n/2)<<"\n" ;
else
cout<<s.substr(n-n/2 , n/2) ;
return 0 ;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |