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"
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
#define rep1n(i, n) for (int i = 1; i <= (n); ++i)
#define repr(i, n) for (int i = (n) - 1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define fr first
#define mp make_pair
#define sc second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define each(x, a) for (auto &x : a)
#define vec vector
#define TURBO {ios::sync_with_stdio(0); cin.tie(0);}
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using str = string;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pair<int, int>>;
using vvi = vector<vi>;
void solve(){
int n, c = 0;
string s;
cin >> n >> s;
string ans = "";
for(int i = 0; i < n; i++){
string res = "", res2 = "";
for (int j = 0; j < n; j++){
if (i == j)continue;
if (res.size() < n / 2)res += s[j];
else res2 += s[j];
}
if (res == res2 && res.size() > 0){
++c;
ans = res;
}
}
if (c == 0)cout << "NOT POSSIBLE";
else if (c == 1)cout << ans;
else cout << "NOT UNIQUE";
}
int main(){
TURBO;
int tt = 1;
// cin >> tt;
while(tt--){
solve();
}
}
Compilation message (stderr)
friends.cpp: In function 'void solve()':
friends.cpp:42:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
42 | if (res.size() < n / 2)res += s[j];
| ~~~~~~~~~~~^~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |