제출 #398814

#제출 시각아이디문제언어결과실행 시간메모리
398814ALI_SQUARED세 명의 친구들 (BOI14_friends)C++14
100 / 100
104 ms15260 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s, a = "", b = "", c = "", d = "", answer1 = "", answer2 = ""; cin >> s; if (n % 2 == 0){cout << "NOT POSSIBLE"; return 0;} for (int i = 0; i < n; i++){ if (i < n/2) a += s[i], c += s[i]; else if (i == n/2) b += s[i], c += s[i]; else b += s[i], d += s[i]; } string x = "", y = ""; int add = 0; for (int i = 0; i < n/2; i++){ if (a[i] == b[i+add]) x += a[i], y += b[i+add]; else x += a[i], y += b[i+1], add = 1; } if (x == y) answer1 = x; x = "", y = ""; add = 0; for (int i = 0; i < n/2; i++){ if (d[i] == c[i+add]) x += d[i], y += c[i+add]; else x += d[i], y += c[i+1], add = 1; } if (x == y) answer2 = x; //cout << "answer2: " << answer2 << "\n"; if (answer1.size() && answer2.size() && answer1 != answer2) cout << "NOT UNIQUE"; else if (!answer1.size() && !answer2.size()) cout << "NOT POSSIBLE"; else if (answer1.size()) cout << answer1; else cout << answer2; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...