# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
217614 | KoalaMuch | Three Friends (BOI14_friends) | C++14 | 79 ms | 8300 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 N = 2000005;
char s[N];
vector< char > ans1;
vector< char > ans2;
void pr(vector< char > v)
{
for(char x : v) printf("%c",x);
printf("\n");
}
int main()
{
int n;
scanf("%d %s",&n,s+1);
if(!(n&1)) return puts("NOT POSSIBLE"),0;
int cur = 1;
for(int i=n/2+1;i<=n;i++)
{
if(cur<n/2+1&&s[i]==s[cur]) ++cur;
}
if(cur==n/2+1) for(int i=1;i<=n/2;i++) ans1.push_back(s[i]);
cur = (n+1)/2+1;
for(int i=1;i<=(n+1)/2;i++)
{
if(cur<n&&s[i]==s[cur]) ++cur;
}
if(cur==n) for(int i=(n+1)/2+1;i<=n;i++) ans2.push_back(s[i]);
if(ans1.empty()&&ans2.empty()) printf("NOT POSSIBLE\n");
else if(!ans1.empty()&&ans2.empty()) pr(ans1);
else if(!ans2.empty()&&ans1.empty()) pr(ans2);
else if(ans1==ans2) pr(ans1);
else printf("NOT UNIQUE\n");
return 0;
}
/*
7
ABXCABC
6
ABCDEF
17
AABBAABBAABBAABBA
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |