제출 #398768

#제출 시각아이디문제언어결과실행 시간메모리
398768ALI_SQUARED세 명의 친구들 (BOI14_friends)C++14
0 / 100
74 ms9388 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s, a = "", b = "", answer1 = "", answer2 = ""; int c = 0; cin >> s; if (n % 2 == 0){cout << "Not Possible"; return 0;} for (int i = 0; i < n/2; i++){ if (s[i] == s[n/2 + i + c]) { a += s[i], b += s[n/2 + i + c]; } else{ if (s[n/2 + i + 1] != s[i]){a = 'z', b = 'x'; break;} else a += s[i], b += s[n/2 + i + 1], c = 1; } //cout << "a: " << a << " b: " << b << "\n"; } if (a == b) answer1 = a; //cout << "answer1: " << answer1 << "\n"; a = "", b = "", c = 0; for (int i = 0; i < n/2; i++){ if (s[i + c] == s[n/2 + i + 1]){ a += s[i + c], b += s[n/2 + i + 1]; } else{ if (s[i + 1] != s[n/2 + i + 1]){a = 'z', b = 'x'; break;} else a += s[i + 1], b += s[n/2 + i + 1], c = 1; } //cout << "a: " << a << " b: " << b << "\n"; } if (a == b) answer2 = b; //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...