Submission #44315

#TimeUsernameProblemLanguageResultExecution timeMemory
44315dhruvsomaniThree Friends (BOI14_friends)C++14
0 / 100
29 ms5580 KiB
#include <iostream> #include <iomanip> #include <fstream> #include <cmath> #include <string> #include <algorithm> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; int n; string s, temp; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; cin >> s; if (n%2 == 0) { cout << "NOT POSSIBLE"; return 0; } set<string> count; int one, two; bool done, poss; one = 1; two = n/2 + 1; done = true; poss = true; temp = ""; while(two < n) { if (s[one] != s[two]) { if (!done) { done = true; one++; } else { poss = false; break; } } else { temp += s[one]; one++; two++; } } one = 0; two = n/2 + 1; done = false; poss = true; temp = ""; while(two < n) { if (s[one] != s[two]) { if (!done) { done = true; one++; } else { poss = false; break; } } else { temp += s[one]; one++; two++; } } if (poss) count.insert(temp); one = 0; two = n/2; done = false; poss = true; temp = ""; while(two < n) { if (s[one] != s[two]) { if (!done) { done = true; two++; } else { poss = false; break; } } else { temp += s[one]; one++; two++; } } if (poss) count.insert(temp); if (count.size() == 0) cout << "NOT POSSIBLE"; else if (count.size() == 1) cout << *(count.begin()); else cout << "NOT UNIQUE"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...