-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path219A_K-String.cpp
More file actions
47 lines (47 loc) · 908 Bytes
/
219A_K-String.cpp
File metadata and controls
47 lines (47 loc) · 908 Bytes
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
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int k;
cin>>k;
string s;
cin>>s;
sort(s.begin(),s.end());
int n=s.size(),count=0;;
/* unordered_map<char,int>mp;
for(int i=0; i<n; i++)
mp[s[i]]++;
for(auto it: mp)
{
if(mp[it.first]%k!=0)
{
count++;
break;
}
}
*/
char ch;
for(int i=0;i<s.size();i++){
if(i%k==0){
cout<<i<<" "<<s[i]<<endl;
ch=s[i];
}
if(s[i]==ch){
count++;
}
}
cout<<count<<endl;
//if(n%k!=0 || count>0)
if(n==count && count%k==0)
cout<<-1<<endl;
else
{
for(int i=0;i<k;i++){
for(int l=0;l<s.size();l+=k){
cout<<s[l];
}
}
}
cout<<endl;
}