제출 #62449

#제출 시각아이디문제언어결과실행 시간메모리
62449RezwanArefin01세 명의 친구들 (BOI14_friends)C++17
100 / 100
136 ms24524 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; string s; set<string> st; void match(int l1, int r1, int l2, int r2) { bool flag = 0; string x = ""; while(l1 <= r1) { if(s[l1] != s[l2]) { if(flag) return; flag = 1; --l1; } else x += s[l1]; ++l1, ++l2; } if(flag || (l2 <= r2 && !flag)) st.insert(x); } int main(int argc, char const *argv[]) { int n; cin >> n >> s; if(~n & 1) return 0*puts("NOT POSSIBLE"); int x = n >> 1; match(0, x - 1, x, n - 1); match(x + 1, n - 1, 0, x); if(!st.size()) puts("NOT POSSIBLE"); else if(st.size() > 1) puts("NOT UNIQUE"); else cout << *st.begin() << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...