#include <bits/stdc++.h>
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long i64;
#define speed_up ios::sync_with_stdio(false);cin.tie(nullptr);
#define ordered_set(datatype) tree<datatype,null_type,less<datatype>,rb_tree_tag,tree_order_statistics_node_update>
template<class T> using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define isON(N,K) (N&(1<<K))
#define endl '\n'
const int N = 2e3 + 7;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;
long double EPS = 1e-9;
const int NOT_VISITED=0,IN_PROGRESS=1,VISITED=3;
const int dr[]={-1,0,1,0};
const int dc[]={0,1,0,-1};
template<class T>
istream &operator>>(istream &in, vector<T> &v) {
for (auto &it : v) in >> it;
return in;
}
template<class T>
ostream &operator<<(ostream &out, vector<T> &v) {
for (auto &it : v) out << it << ' ';
return out;
}
vector<i64> get_div(i64 n){
vector<i64>v;
for (i64 i = 1; i*i <= n; ++i) {
if(n%i==0){
if(n/i==i)v.push_back(i);
else{v.push_back(i);v.push_back(n/i);}
}
}
return v;
}
void TC(){
int n;
cin >> n;
string s,ans;
cin >> s;
if(n%2==0)return void(cout << "NOT POSSIBLE");
map<int,int>mp;
for(auto &i:s)mp[i]++;
bool f=false;
for(auto &i:mp){
if(i.second==2)ans.push_back(i.first);
}
if(ans.size()==n/2)cout << ans;
else cout << "NOT UNIQUE";
}
signed main() {
speed_up
int tt = 1;
// cin >> tt;
while(tt--) {
TC();
cout << endl;
}
}
Compilation message
friends.cpp: In function 'void TC()':
friends.cpp:62:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
62 | if(ans.size()==n/2)cout << ans;
| ~~~~~~~~~~^~~~~
friends.cpp:58:10: warning: unused variable 'f' [-Wunused-variable]
58 | bool f=false;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
352 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
600 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
48 ms |
2552 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |