# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
930623 | yeehaw | Three Friends (BOI14_friends) | C++17 | 46 ms | 5340 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 int long long
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
int32_t main(){
ios::sync_with_stdio(0);cin.tie(0);
int n;cin>>n;
char a[n];
for(int i=0;i<n;i++)cin>>a[i];
if(n%2==0){
cout<<"NOT POSSIBLE";
return 0;
}
int in=n/2,c=0,co=2,s=1,f=1;
for(int i=0;i<n/2;i++){
if(a[i]==a[i+in+c]);
else{
i--;
if(c==1){
f=0;
co--;
break;
}c++;
}
}
in++;c=0;
for(int i=0;i<n/2;i++){
if(a[i+c]==a[i+in]);
else{
i--;
if(c==1){
s=0;
co--;
break;
}c++;
}
}
if(co==2)cout<<"NOT UNIQUE";
else if(co==0)cout<<"NOT POSSIBLE";
else{
if(s){
c=0;
for(int i=0;i<n/2;i++){
if(a[i+c]==a[i+n/2+1])cout<<a[i+c];
else {i--;c++;}
}
}else{
c=0;
for(int i=0;i<n/2;i++){
if(a[i]==a[i+n/2+1+c])cout<<a[i];
else {i--;c++;}
}
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |