# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
337669 | Sho10 | Three Friends (BOI14_friends) | C++14 | 13 ms | 8208 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> //Andrei Alexandru a.k.a Sho10
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n;
string s;
vector<string>ans;
void calc(string a,string b){
ll cnt[3];
cnt[0]=cnt[1]=cnt[2]=0;
while(cnt[0]<a.size()&&cnt[1]<b.size()){
if(a[cnt[0]]==b[cnt[1]]){
cnt[0]++;
cnt[1]++;
}else {
cnt[2]++;
cnt[1]++;
}
}
if(cnt[2]>1){
return;
}
if(ans.empty()){
ans.pb(a);
return;
}
if(ans[0]!=a){
ans.pb(a);
return;
}
}
int32_t main(){
CODE_START;
cin>>n;
cin>>s;
if(n%2==0){
cout<<"NOT POSSIBLE"<<endl;
return 0;
}
n/=2;
calc(s.substr(0,n),s.substr(n,n+1));
calc(s.substr(n+1,n),s.substr(0,n+1));
if(ans.empty()){
cout<<"NOT POSSIBLE"<<endl;
}else if(ans.size()==1){
cout<<ans[0]<<endl;
}else {
cout<<"NOT UNIQUE"<<endl;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |