이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pff pair<float, float>
#define coutpair(p) cout << p.first << " " << p.second << "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n; cin >> n;
string s; cin >> s;
if (n%2==0 || n < 3){
cout << "NOT POSSIBLE";
return 0;
}
set<string> st;
string s1, s2;
int mid = n/2;
for (int i=mid+1; i<n; i++) s1 += s[i];
int p1, p2;
for(p1=0; p1<mid; p1++){
if (s[p1] != s1[p1]) break;
}
for(p2=mid; p2>0; p2--){
if (s[p2] != s1[p2-1]) break;
}
if (p1 >= p2) st.insert(s1);
for (int i=0; i<mid; i++) s2 += s[i];
for (p1=mid; p1<n-1; p1++){
if (s[p1] != s2[p1-mid]) break;
}
for(p2=n-1; p2>mid; p2--){
if (s[p2] != s2[p2-1-mid]) break;
}
if (p1 >= p2) st.insert(s2);
if (st.size() > 1) cout << "NOT UNIQUE";
else if (st.size() == 1) cout << *st.begin();
else cout << "NOT POSSIBLE";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |