이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
* pair : first second
* binary : lower_bound upper_bound
* strings : tolower toupper
* vector : push_back erase begin
* set : insert
**/
/*
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define un unsigned
#define MAXN 200004
ll n, a, b, r, x1, x2;
string str;
int main()
{
//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> str;
if (n % 2 == 0) {
cout << "NOT POSSIBLE";
return 0;
}
int sSize = n / 2 + 1;
string s1(sSize, 'a'), s2(sSize,'a'), s3(sSize-1, 'a');
int j = 0;
for (int i = 0; i <= n/2; i++)
{
s1[j] = str[i];
j++;
}
j = 0;
for (int i = n/2; i < n; i++)
{
s2[j] = str[i];
j++;
}
x1 = x2 = r = 0;
for (int i = 0; i <= n / 2; i++)
{
if (s1[i+x1]==s2[i+x2]) {
r++;
//cout << s1[i + x1] << " " << s2[i + x2] << "\n";
}
else if (i!= n / 2) {
if (x1 + x2 == 0 && s1[i + 1] == s2[i]) {
x1 = 1;
r++;
//cout << s1[i + x1] << " " << s2[i + x2] << "\n";
}
else if (x1 + x2 == 0 && s1[i] == s2[i + 1]) {
x2 = 1;
r++;
//cout << s1[i + x1] << " " << s2[i + x2] << "\n";
}
else if (s1[i + 1] == s2[i + 1]) {
x1 = x2 = 1;
r++;
//cout << s1[i + x1] << " " << s2[i + x2] << "\n";
}
}
if(i< n / 2)s3[i] = s1[i + x1];
if (x1 + x2 > 0 && i == n / 2-1)break;
}
if (r == sSize) {
cout << "NOT UNIQUE";
}
else if (r + 1 == sSize) {
cout << s3;
}
else {
cout << "NOT POSSIBLE";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |