# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
217603 | KoalaMuch | Three Friends (BOI14_friends) | C++14 | 68 ms | 7404 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 = n/2+1;
bool ch = false;
for(int i=1;i<=n/2;i++)
{
while(s[i]!=s[cur]&&cur<=n) ++cur;
if(s[i]!=s[cur]|cur==n+1) {ch = true;break;}
}
if(!ch) for(int i=1;i<=n/2;i++) ans1.push_back(s[i]);
cur = 1,ch = false;
for(int i=(n+1)/2+1;i<=n;i++)
{
while(s[i]!=s[cur]&&cur<=(n+1)/2) ++cur;
if(s[i]!=s[cur]||cur==(n+1)/2+1) {ch=true;break;}
}
if(!ch) 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.empty()&&ans1!=ans2) printf("NOT UNIQUE\n");
else pr(ans1);
return 0;
}
/*
7
ABXCABC
6
ABCDEF
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |