Submission #1243175

#TimeUsernameProblemLanguageResultExecution timeMemory
1243175chikien2009세 명의 친구들 (BOI14_friends)C++20
35 / 100
1095 ms5092 KiB
#include <bits/stdc++.h> using namespace std; void setup() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int n; string s; bool a, b; inline bool Check(string edited, string base) { string cur = edited; cur.erase(cur.begin()); if (cur == base) { return true; } for (int i = 0; i < base.size(); ++i) { cur[i] = edited[i]; if (cur == base) { return true; } } return false; } int main() { setup(); cin >> n >> s; if (!(n & 1)) { cout << "NOT POSSIBLE"; return 0; } a = Check(s.substr(0, n / 2 + 1), s.substr(n / 2 + 1, n / 2)); b = Check(s.substr(n / 2, n / 2 + 1), s.substr(0, n / 2)); if (a && b) { cout << (s.substr(0, n / 2) == s.substr(n / 2 + 1, n / 2) ? s.substr(0, n / 2) : "NOT UNIQUE"); } else if (a) { cout << s.substr(n / 2 + 1, n / 2); } else if (b) { cout << s.substr(0, n / 2); } else { cout << "NOT POSSIBLE"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...