# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
735667 | josanneo22 | Three Friends (BOI14_friends) | C++17 | 14 ms | 6148 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<stdio.h>
int n;
char a[2001000];
char b[2001000];
int main(){
int i,t,flag;
scanf("%d",&n);
scanf("%s",a);
if(n%2==0){
puts("NOT POSSIBLE");
return 0;
}
for(i=0;i<n/2;i++){
if(a[i]!=a[i+n/2])break;
}
t=i;
for(i=n/2-1;i>=0;i--){
if(a[i]!=a[i+n/2+1])break;
}
if(t>i)flag=1;
else flag=0;
for(i=0;i<n/2+1;i++){
if(a[i]!=a[i+n/2+1])break;
}
t=i;
for(i=n/2;i>=0;i--){
if(a[i]!=a[i+n/2])break;
}
if(t>=i){
if(flag==1){
for(i=0;i<n/2;i++){
if(a[i]!=a[i+n/2+1])break;
}
if(i==n/2){
for(i=0;i<n/2;i++){
b[i]=a[i];
}
puts(b);
}
else{
puts("NOT UNIQUE");
}
}
else{
for(i=0;i<n/2;i++){
b[i]=a[i+n/2+1];
}
puts(b);
}
}
else{
if(flag==1){
for(i=0;i<n/2;i++){
b[i]=a[i];
}
puts(b);
}
else{
puts("NOT POSSIBLE");
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |