# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
625620 | kkkkkkkk | Three Friends (BOI14_friends) | C++14 | 82 ms | 6272 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;
int main()
{
int n;
string s;
cin >> n >> s;
if (n%2==0)
{
cout << "NOT POSSIBLE" << endl;
return 0;
}
int cnt=0,poz=-1;
bool ok=true,moze=true;
for (int i=0,j=n/2+1;j<n,i<=n/2;)
{
if (s[i]==s[j])
i++,j++;
else if (s[i]!=s[j]&&ok==true)
poz=i,i++,ok=false;
else
{
moze=false;
break;
}
}
if (moze)
cnt++;
ok=true,moze=true;
for (int i=0,j=n/2;j<n,i<n/2;)
{
if (s[i]==s[j])
i++,j++;
else if (s[i]!=s[j]&&ok==true)
{
if (poz==-1)
poz=j;
j++,ok=false;
}
else
{
moze=false;
break;
}
}
if (moze)
cnt++;
if (cnt==0)
cout << "NOT POSSIBLE" << endl;
if (cnt==1)
{
//cout << poz << endl;
if (poz>=n/2)
{
for (int i=0;i<n/2;i++)
cout << s[i];
}
else
{
for (int i=n/2+1;i<n;i++)
cout << s[i];
}
}
else
cout << "NOT UNIQUE" << endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |