# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
107564 | patrikpavic2 | Three Friends (BOI14_friends) | C++17 | 69 ms | 6136 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 <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#include <map>
#define X first
#define Y second
#define PB push_back
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef vector < int > vi;
typedef set < int > si;
const int N = 1e5 + 500;
const int M = 1e6 + 500;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int OFF = (1 << 18);
const int LOG = 20;
const double EPS = 1e-9;
const double PI = 3.1415926535;
char s[2 * M], ans[2 * M];
int cnt, n, can = 0;
int main(){
scanf("%d", &n);
if(n % 2 == 0){
printf("NOT POSSIBLE\n");
return 0;
}
scanf("%s", s);
int j = n / 2;
for(int i = 0;2 * i + 1 < n;i++,j++){
if(s[i] != s[j]) cnt++,i--;
if(cnt > 1) break;
}
if(cnt <= 1){
for(int i = 0;2 * i + 1 < n;i++)
ans[i] = s[i];
can++;
}
cnt = 0;j = 0;
for(int i = n / 2 + 1;i < n;i++,j++){
if(s[i] != s[j]) cnt++,i--;
if(cnt > 1) break;
}
if(cnt <= 1){
for(int i = n / 2 + 1;i < n;i++){
if(ans[i - n / 2 - 1] != s[i] && can){
printf("NOT UNIQUE\n");
return 0;
}
ans[i - n / 2 - 1] = s[i];
}
can++;
}
if(!can) printf("NOT POSSIBLE\n");
else{
for(int i = 0;2 * i + 1 < n;i++)
printf("%c", ans[i]);
printf("\n");
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |