# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
105601 | pamaj | Three Friends (BOI14_friends) | C++14 | 1069 ms | 8520 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;
int main()
{
int n;
cin >> n;
if(n%2 == 0) cout << "NOT POSSIBLE\n";
else
{
int cnt[30];
memset(cnt, 0, sizeof(cnt));
int sz = n/2;
string s;
cin >> s;
for(int i = 0; i < n; i++)
{
cnt[s[i] - 'A']++;
}
int lt = -1;
for(int i = 0; i < 26; i++)
{
if(cnt[i]%2)
{
if(lt == -1) lt = i;
else
{
cout << "NOT POSSIBLE\n";
}
}
}
//cout << lt << "\n";
string temp;
for(int i = 0; i < s.size(); i++)
{
if(s[i] - 'A' == lt)
{
//cout << i << "\n";
string tmp;
string pass;
bool ok = true;
for(int j = 0; j < n; j++)
{
if(j == i) continue;
tmp += s[j];
}
//cout << tmp << "\n";
for(int j = 0; j < sz; j++)
{
if(tmp[j] == tmp[j + sz])
{
pass += tmp[j];
}
else ok = false;
}
//cout << ok << "\n";
if(ok)
{
if((int)temp.size())
{
cout << "NOT UNIQUE\n";
return 0;
}
else temp = pass;
}
}
}
cout << temp << "\n";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |