Submission #84689

#TimeUsernameProblemLanguageResultExecution timeMemory
84689teomrnThree Friends (BOI14_friends)C++14
100 / 100
85 ms25308 KiB
#include <bits/stdc++.h> using namespace std; string ans; bool uniq; void proc(string a, string b) { if (a.size() < b.size()) swap(a, b); char c = 0; int p = 0; for (auto i : a) { if (p == b.size() || b[p] != i) { if (c) return; c = i; p--; } p++; } if (c) { if (!ans.empty() && ans != b) uniq = 1; ans = b; } } int main() { int l; cin >> l; string s; cin >> s; if (l % 2 == 0) { cout << "NOT POSSIBLE\n"; return 0; } proc(s.substr(0, l / 2), s.substr(l / 2, l / 2 + 1)); proc(s.substr(0, l / 2 + 1), s.substr(l / 2 + 1, l / 2)); if (uniq) cout << "NOT UNIQUE\n"; else if (ans.empty()) cout << "NOT POSSIBLE\n"; else cout << ans << '\n'; return 0; }

Compilation message (stderr)

friends.cpp: In function 'void proc(std::__cxx11::string, std::__cxx11::string)':
friends.cpp:14:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (p == b.size() || b[p] != i) {
             ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...