Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Description

You are given a string q. A sequence of k strings s1, s2, ..., sk is called beautiful, if the concatenation of these strings is string q(formally, s1 + s2 + ... + sk = q) and the first characters of these strings are distinct.

Find any beautiful sequence of strings or determine that the beautiful sequence doesn't exist.

Input

The first line contains a positive integer k (1 ≤ k ≤ 26) — the number of strings that should be in a beautiful sequence.

The second line contains string q, consisting of lowercase Latin letters. The length of the string is within range from 1 to 100, inclusive.

Output

If such sequence doesn't exist, then print in a single line "NO" (without the quotes). Otherwise, print in the first line "YES" (without the quotes) and in the next k lines print the beautiful sequence of strings s1, s2, ..., sk.

If there are multiple possible answers, print any of them.

Sample Input

Input
1
abca
Output
YES
abca
Input
2
aaacas
Output
YES
aaa
cas
Input
4
abc
Output
NO

Hint

In the second sample there are two possible answers: {"aaaca", "s"} and {"aaa", "cas"}.

题意:

给你k和一个字符串q,求能否将q分为k份且每一份的首字符各不相同。

可用map来筛选不同的字母的个数,可分为k段则至少有k个不同的字母。输出时再用map记录以用过的首字母。

附AC代码:

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<algorithm>
using namespace std; int main(){
string s,a;
int k,lens,lenm;
cin>>k>>s;
int t=,temp=,ans=;
map<char,int> m;
lens=s.size();
for(int i=;i<lens;i++){
m[s[i]]=;
}
lenm=m.size();
a[]=s[];
if(lens>=k&&lenm>=k){
m.clear();
cout<<"YES"<<endl;
for(int i=;i<lens;i++){
if(m[s[i]]== && temp<k){
if(temp) cout<<endl;
temp++;
}
m[s[i]]++;
cout<<s[i];
}
}
else{
cout<<"NO"<<endl;
}
return ;
}

最新文章

  1. 【推荐】CentOS安装PHP-5.6.4+扩展安装+安全配置+性能配置
  2. [z]Java开发必会的Linux命令
  3. 说说设计模式~门面模式(Facade)
  4. Lua使用心得(2)
  5. go println与printf区别
  6. 63.Hbase 常用命令
  7. Android之图片窗口和大小调节
  8. /system改成可写
  9. iphone屏幕镜像怎么用 手机投屏电脑
  10. SPOJ GSS系列
  11. Java POI 读取word文件
  12. (3.1)mysql基础深入——mysql二进制与源码目录结构介绍
  13. Linux系统——PXE高效能批量网络装机
  14. tomcat启动时端口占用的问题怎么解决
  15. Configure Pi as simulation hardware for Simulink
  16. 理解webpack4.splitChunks
  17. Spring Cloud Netflix之Eureka 相关概念
  18. BestCoder Round #86 二,三题题解(尺取法)
  19. cocos2d-js中怎么删除一个精灵
  20. Linux介绍和基本命令

热门文章

  1. xml文件的根节点layout_width或者layout_height设置无效果的原因分析
  2. 2016年第七届蓝桥杯c/c++省赛B组
  3. 内核顶层Makefile相关4
  4. 实习日记)select option 选择不同的option时, 页面发生不同的变化
  5. JSP 随记
  6. vim tips 集锦
  7. JSP之Model1
  8. 实例具体解释:反编译Android APK,改动字节码后再回编译成APK
  9. Spark SQL includes a cost-based optimizer, columnar storage and code generation to make queries fast.
  10. finding friends with mapreduce