# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
432351 | cpp219 | Three Friends (BOI14_friends) | C++14 | 35 ms | 10052 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.
#pragma GCC optimization "O2"
#pragma GCC optimization "unroll-loop"
#pragma GCC target ("avx2")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
using namespace std;
const ll N = 2e6 + 9;
const ll mod = 1e9 + 7;
const ll base = 31;
typedef pair<ll,ll> LL;
string s;
string p,q;
vector<string> ans;
ll n;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
#define task "tst"
if (fopen(task".inp", "r")){
freopen(task".inp", "r", stdin);
//freopen(task".out", "w", stdout);
}
cin>>n>>s; s = " " + s;
if (n%2 == 0) return cout<<"NOT POSSIBLE",0;
/// X to head
ll pos = 1;
while(pos <= n/2 && s[pos] == s[pos + n/2]) pos++;
for(ll i = 1;i <= n/2;i++) p += s[i];
for (ll i = n/2 + 1;i <= n;i++) if (i != pos + n/2) q += s[i];
if (p == q) ans.push_back(p);
p = ""; q = ""; pos = 1;
while(pos <= n/2&&s[pos] == s[pos + 1 + n/2]) pos++;
for(ll i = 1;i <= n/2 + 1;i++) if (i != pos) p += s[i];
for (ll i = n/2 + 2;i <= n;i++) q += s[i];
if (p == q) ans.push_back(p);
if (!ans.size()) cout<<"NOT POSSIBLE";
else if (ans.size() == 1) cout<<ans[0];
else{
if (ans[0] != ans[1]) cout<<"NOT UNIQUE";
else cout<<ans[0];
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |