# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
398567 | iulia13 | Three Friends (BOI14_friends) | C++14 | 91 ms | 5192 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 <iostream>
using namespace std;
const int nmax = 2e6 + 5;
char v[nmax];
int main()
{
int n, i = 1, j = 1, ok = 0;
cin >> n;
if (n % 2 == 0)
{
cout << "NOT POSSIBLE";
return 0;
}
cin >> v + 1;
int skip = 0;
///primele n / 2 sunt suuuper
for (i = n / 2 + 1; i <= n && skip < 2 && j <= n / 2; i++)
{
if (v[i] == v[j])
j++;
else
skip++;
}
if (skip < 2)
ok = 1;
skip = 0;
j = n / 2 + 2;
///ult n / 2 sunt suuuuuuuuuper
for (i = 1; i <= n / 2 + 1 && j <= n && skip < 2; i++)
{
if (v[i] == v[j])
j++;
else
skip++;
}
if (skip < 2)
ok += 2;
if (ok == 3)
{
cout << "NOT UNIQUE";
return 0;
}
if (!ok)
{
cout << "NOT POSSIBLE";
return 0;
}
if (ok == 1)
{
for (i = 1; i <= n/ 2; i++)
cout << v[i];
}
else
{
for (i = n / 2 + 2; i <= n; i++)
cout << v[i];
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |