# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
26466 | WhipppedCream | Three Friends (BOI14_friends) | C++14 | 79 ms | 3972 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 X first
#define Y second
#define pb push_back
#define mp make_pair
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector< ii > vii;
typedef long long L;
typedef vector< L > vL;
typedef vector< vL > vvL;
typedef vector< vi > vvi;
typedef vector< vii > vvii;
const int inf = 1e9;
const L inf8 = 1e18;
const int maxn = 2e6 + 5;
const int md = 1e9 + 7;
void np()
{
puts("NOT POSSIBLE"); exit(0);
}
void nu()
{
puts("NOT UNIQUE"); exit(0);
}
char s[maxn];
int main()
{
int n; scanf("%d", &n);
scanf("%s", s);
if(n%2 == 0 || n<= 2) np();
int a = 0, b = 0;
int skipped = 0;
int ptr = n/2;
bool bad = 0;
for(int i = 0; i< n/2; i++)
{
if(s[i] == s[ptr]) ptr++;
else if(!skipped)
{
skipped = 1;
i--;
ptr++;
}
else
{
bad = 1;
break;
}
}
if(!bad) a = 1;
skipped = 0; bad = 0; ptr = 0;
for(int i = n/2+1; i< n; i++)
{
if(s[i] == s[ptr]) ptr++;
else if(!skipped)
{
skipped = 1;
i--;
ptr++;
}
else
{
bad = 1; break;
}
}
bool same = 1;
for(int i = 0; i< n/2; i++) if(s[i] != s[n/2+i+1]) same = 0;
if(!bad) b = 1;
if(a&&b && !same) nu();
if(a+b == 0) np();
if(a) for(int i = 0; i< n/2; i++) printf("%c", s[i]);
else for(int i = n/2+1; i< n; i++) printf("%c", s[i]);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |