# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
44321 | dhruvsomani | Three Friends (BOI14_friends) | C++14 | 31 ms | 5692 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 = 0;
two = n/2 + 1;
done = false;
poss = true;
temp = "";
while((two < n) && (temp.size() < n/2)) {
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) && (temp.size() < n/2)) {
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;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |