forked from anshuman8800/Interivew-Questions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathk_strings.cpp
More file actions
53 lines (49 loc) · 1.01 KB
/
k_strings.cpp
File metadata and controls
53 lines (49 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*https : // codeforces.com/contest/219/problem/A*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll M = 1e9 + 7;
#define REP(i, a, b) for (int i = a; i <= b; i++)
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
int main()
{
int t = 1;
// cin>>t;
while (t--)
{
int k;
cin >> k;
string s;
cin >> s;
map<char, int> m;
int flag = 0;
REP(i, 0, s.size() - 1)
{
m[s[i]]++;
}
for (auto mtr : m)
{
if (mtr.second % k != 0)
{
flag = 1;
break;
}
}
if (flag == 1)
cout << "-1" << endl;
else
{
string s1 = "";
for (auto mtr : m)
{
for (int i = 1; i <= mtr.second / k; i++)
s1 = s1 + mtr.first;
}
for (int i = 1; i <= k; i++)
cout << s1;
}
}
}