# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
91722 | Mercenary | Three Friends (BOI14_friends) | C++14 | 20 ms | 10096 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<bits/stdc++.h>
using namespace std;
#define taskname "TEST"
#define pb push_back
typedef long double ld;
typedef long long ll;
const int maxn = 2e6 + 5;
const int mod = 1e9 + 9;
const int base = 33;
int n;
string s;
string can(string need , int st , int en)
{
string res = "";
int it = 0;int ok = 1;
for(int i = st ; i <= en && res.size() < n / 2 ; ++i)
{
if(need[it] == s[i])
res.pb(s[i]) , ++it;
else
{
if(ok == 0)return "-1";
ok = 0;
}
}
return res;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
if(fopen(taskname".INP","r"))
freopen(taskname".INP", "r",stdin) ,
freopen(taskname".OUT", "w",stdout);
cin >> n >> s;
if(n % 2 == 0)return cout << "NOT POSSIBLE" , 0;
s = " " + s;
string res1 = can(s.substr(1,n/2),n/2+1,n);
string res2 = can(s.substr(n/2+2,n/2),1,n/2+1);
if(res1 == "-1" && res2 == "-1")cout << "NOT POSSIBLE";
else if(res1 == "-1")cout << res2;
else if(res2 == "-1")cout << res1;
else if(res1 == res2)cout << res1;
else cout << "NOT UNIQUE";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |