Submission #146286

#TimeUsernameProblemLanguageResultExecution timeMemory
146286meatrowThree Friends (BOI14_friends)C++17
100 / 100
20 ms7324 KiB
#pragma GCC optimize("O3") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native") //#pragma GCC optimize ("unroll-loops") #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; string s; cin >> n >> s; if (n % 2 == 0) { cout << "NOT POSSIBLE"; return 0; } string a = s.substr(0, n / 2); string b = s.substr(n / 2 + 1); int i = 0; for (int j = n / 2; j < n; j++) { if (i < n / 2 && s[j] == a[i]) { i++; } } int cnt = 0; int first = 0; if (i == n / 2) { cnt++; first = 1; } i = 0; for (int j = 0; j <= n / 2; j++) { if (i < n / 2 && s[j] == b[i]) { i++; } } if (i == n / 2) { cnt++; } if (!cnt) { cout << "NOT POSSIBLE"; } if (cnt == 1) { if (first) { cout << a; } else { cout << b; } } if (cnt == 2) { if (a == b) { cout << a; } else { cout << "NOT UNIQUE"; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...