CF Set of Strings

Set of Strings
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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 1to 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 test(s)
input
1
abca
output
YES
abca
input
2
aaacas
output
YES
aaa
cas
input
4
abc
output
NO



 1 #include <cstdio>
 2 #include <iostream>
 3 #include <algorithm>
 4 #include <queue>
 5 #include <cstring>
 6 #include <string>
 7 #include <cstdlib>
 8 #include <cmath>
 9 #include <cctype>
10 #include <map>
11 #include <ctime>
12 using    namespace    std;
13 
14 bool    VIS[30];
15 int    main(void)
16 {
17     char    q[105];
18     int    a,num;
19     int    loc[105];
20     num = 0;
21 
22     scanf("%d",&a);
23     scanf("%s",q);
24     for(int i = 0;q[i];i ++)
25         if(!VIS[q[i]])
26         {
27             VIS[q[i]] = true;
28             loc[num] = i;
29             num ++;
30         }
31     loc[num] = strlen(q);
32 
33     if(num < a)
34         puts("NO");
35     else
36     {
37         puts("YES");
38         for(int i = 0;i < a;i ++)
39         {
40             if(i == a - 1)
41                 for(int j = loc[i];q[j];j ++)
42                     printf("%c",q[j]);
43             else
44                 for(int j = loc[i];j < loc[i + 1];j ++)
45                     printf("%c",q[j]);
46             puts("");
47         }
48     }
49 
50     return    0;
51 }
View Code

 

转载于:https://www.cnblogs.com/xz816111/p/4506925.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值