Submission #398840

#TimeUsernameProblemLanguageResultExecution timeMemory
398840Hassan61Three Friends (BOI14_friends)C++14
0 / 100
56 ms6192 KiB
/** * pair : first second * binary : lower_bound upper_bound * strings : tolower toupper * vector : push_back erase begin * set : insert **/ /* #include <iostream> #include <string> #include <algorithm> #include <vector> */ #include <bits/stdc++.h> using namespace std; #define ll long long #define un unsigned #define MAXN 200004 ll n, a, b, r, x1, x2; string str; int main() { //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> str; if (n % 2 == 0) { cout << "NOT POSSIBLE"; return 0; } int sSize = n / 2 + 1; string s1(sSize, 'a'), s2(sSize,'a'), s3(sSize-1, 'a'); int j = 0; for (int i = 0; i <= n/2; i++) { s1[j] = str[i]; j++; } j = 0; for (int i = n/2; i < n; i++) { s2[j] = str[i]; j++; } x1 = x2 = r = 0; for (int i = 0; i <= n / 2; i++) { if (s1[i+x1]==s2[i+x2]) { r++; //cout << s1[i + x1] << " " << s2[i + x2] << "\n"; } else if (i!= n / 2) { if (x1 + x2 == 0 && s1[i + 1] == s2[i]) { x1 = 1; r++; //cout << s1[i + x1] << " " << s2[i + x2] << "\n"; } else if (x1 + x2 == 0 && s1[i] == s2[i + 1]) { x2 = 1; r++; //cout << s1[i + x1] << " " << s2[i + x2] << "\n"; } else if (s1[i + 1] == s2[i + 1]) { x1 = x2 = 1; r++; //cout << s1[i + x1] << " " << s2[i + x2] << "\n"; } } if(i< n / 2)s3[i] = s1[i + x1]; if (x1 + x2 > 0 && i == n / 2-1)break; } if (r == sSize) { cout << "NOT UNIQUE"; } else if (r + 1 == sSize) { cout << s3; } else { cout << "NOT POSSIBLE"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...