제출 #713929

#제출 시각아이디문제언어결과실행 시간메모리
713929Stickfish세 명의 친구들 (BOI14_friends)C++17
0 / 100
1072 ms6172 KiB
#include <iostream> #include <string> #include <vector> using namespace std; signed main() { int n; cin >> n; string s; cin >> s; if (n % 2 == 0) { cout << "NOT POSSIBLE\n"; return 0; } vector<int> ans; int m = n / 2; for (int i = 0; i < m; ++i) { //cout << "(" << s.substr(0, i) << ' ' << s.substr(m + 1, i) << ") (" << s.substr(i + 1, m - i) << ' ' << s.substr(m + 1 + i, m - i) << ")\n"; if (s.substr(0, i) == s.substr(m + 1, i) && s.substr(i + 1, m - i) == s.substr(m + 1 + i, m - i)) ans.push_back(i); } if (s.substr(0, m) == s.substr(m + 1, m)) ans.push_back(m); for (int i = m + 1; i < n; ++i) { if (s.substr(m, i - m) == s.substr(0, i - m) && s.substr(i + 1, n - 1 - i) == s.substr(i - m, n - i - 1)) ans.push_back(i); } if (ans.empty()) { cout << "NOT POSSIBLE\n"; return 0; } if (ans.size() > 1) { cout << "NOT UNIQUE\n"; return 0; } s.erase(s.begin() + ans[0]); cout << s.substr(0, n / 2); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...