이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
____ _ _ _ _ _ _ _ _ _____ _ _
| _ \ (_) | | (_) | | (_) | | | | (_) / ____| | (_)
| |_) | ___ _ ___| |__ ___ _ __ _ ___ __ _ ___| | __ _ ___ ___ _ ___ _ __ _ __ ___ | |__ | | ___ _ __ ___ _ _ __ | | | |__ _ _ __ __ _
| _ < / _ \ |/ __| '_ \ / _ \ '_ \ | / __| / _` | / __| |/ _` / __/ __| |/ __| | '_ \| '__/ _ \| '_ \| |/ _ \ '_ ` _ \ | | '_ \ | | | '_ \| | '_ \ / _` |
| |_) | __/ | (__| | | | __/ | | | | \__ \ | (_| | | (__| | (_| \__ \__ \ | (__ | |_) | | | (_) | |_) | | __/ | | | | | | | | | | | |____| | | | | | | | (_| |
|____/ \___|_|\___|_| |_|\___|_| |_| |_|___/ \__,_| \___|_|\__,_|___/___/_|\___| | .__/|_| \___/|_.__/|_|\___|_| |_| |_| |_|_| |_| \_____|_| |_|_|_| |_|\__,_|
| |
|_|
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define debug(x) cerr << #x << " is " << x << "\n";
#define hehe ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repb(i, a, b) for (int i = b; i >= a; i--)
#define pii pair<int, int>
#define linebreak cout << "---------------------------------------------------------\n"
// good luck
const int MS = 2e6+5;
int n, cnt[26], a[MS];
char letter[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
int32_t main() {
memset(cnt, 0, sizeof(cnt));
cin >> n;
for (int i = 1; i <= n; i++) {
char temp;
cin >> temp;
a[i] = temp-'A';
}
if (n%2 == 0) {
cout << "NOT POSSIBLE\n"; return 0;
}
int m = n/2;
// answer either lies in either half
int left = 1, right = 1, x = m+1;
for (int i = 1; i <= m; i++) {
while (a[i] != a[x] and x <= n) x++;
if (x >= n+1) {
left = 0; break;
}
x++;
}
x = 1;
for (int i = m+2; i <= n; i++) {
while (a[i] != a[x] and x <= m+1) x++;
if (x >= m+2) {
right = 0; break;
}
x++;
}
if (left == 0 and right == 0) {
cout << "NOT POSSIBLE\n";
return 0;
}
if (left == 1 and right == 1) {
for (int i = 1; i <= m; i++) {
if (a[i] != a[i+m+1]) {
cout << "NOT UNIQUE\n";
return 0;
}
}
for (int i = 1; i <= m; i++) cout << letter[a[i]];
}
if (left == 1 and right == 0) {
for (int i = 1; i <= m; i++) cout << letter[a[i]];
return 0;
}
if (right == 1 and left == 0) {
for (int i = m+2; i <= n; i++) cout << letter[a[i]];
return 0;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |