제출 #1026212

#제출 시각아이디문제언어결과실행 시간메모리
1026212VMaksimoski008세 명의 친구들 (BOI14_friends)C++17
100 / 100
52 ms12808 KiB
#include <bits/stdc++.h> #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() //#define int long long using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; const int mod = 1e9 + 7; const int LOG = 20; const int maxn = 1e5 + 5; string check(string s) { int n = s.size(); int len = (n - 1) / 2; string A = ""; for(int i=0; i<len; i++) A += s[i]; string B = ""; for(int i=len; i<n; i++) { if(s[i] == A[B.size()]) B += s[i]; } // cout << A << " " << B << '\n'; if(A == B) return A; return "-1"; } signed main() { int n; cin >> n; if(n % 2 == 0) { cout << "NOT POSSIBLE\n"; return 0; } string s; cin >> s; string A = check(s); reverse(s.begin(), s.end()); string B = check(s); if(A == "-1" && B == "-1") { cout << "NOT POSSIBLE\n"; } else if(B == "-1") { cout << A << '\n'; } else if(A == "-1") { reverse(B.begin(), B.end()); cout << B << '\n'; } else { reverse(B.begin(), B.end()); if(A == B) cout << A << '\n'; else cout << "NOT UNIQUE\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...