# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
742000 | MODDI | Three Friends (BOI14_friends) | C++14 | 1061 ms | 8168 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 pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
int n;
string str;
int main(){
cin>>n>>str;
int cnt = 0;
map<string, int> ans;
string out;
for(int i = 0; i < n; i++){
string l, r;
int sz = n/2;
for(int j = 0; j < n; j++){
if(j == i) continue;
else if(l.size() < sz) l.pb(str[j]);
else r.pb(str[j]);
}
bool ok = true;
for(int j = 0; j < l.size(); j++){
if(l[j] != r[j]){
ok = false;break;
}
}
if(ok){
if(ans[l] == 0){
// cout<<l<<endl;
out = l;
cnt++;
ans[l] = 1;
}
}
}
if(cnt == 1){
cout<<out<<endl;
}
else if(cnt > 1) cout<<"NOT UNIQUE"<<endl;
else cout<<"NOT POSSIBLE"<<endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |