题目传送门

 /*
题意:一个字符串分割成k段,每段开头字母不相同
水题:记录每个字母出现的次数,每一次分割把首字母的次数降为0,最后一段直接全部输出
*/
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std; const int MAXN = 1e2 + ;
const int INF = 0x3f3f3f3f;
char s[MAXN];
int num[]; int main(void) //Codeforces Round #302 (Div. 2) A Set of Strings
{
//freopen ("A.in", "r", stdin); int k;
while (scanf ("%d", &k) == )
{
scanf ("%s", &s);
if (k == ) {puts ("YES"); printf ("%s\n", s); continue;} memset (num, , sizeof (num));
int len = strlen (s);
for (int i=; i<len; ++i) num[s[i]-'a']++;
int t = ;
for (int i=; i<; ++i) if (num[i]) ++t;
if (t < k) {puts ("NO"); continue;} puts ("YES");
printf ("%c", s[]); num[s[]-'a'] = ;
int p = ; int i;
for (i=; i<len; ++i)
{
if (!num[s[i]-'a']) {printf ("%c", s[i]);}
else
{
num[s[i]-'a'] = ; puts ("");
printf ("%c", s[i]); ++p;
}
if (p == k - ) break;
} for (int j=i+; j<len; ++j) printf ("%c", s[j]);
puts ("");
} return ;
}

最新文章

  1. [outlook]打开以后就自动进入安全模式的解决方法。Outlook start in safe mode.
  2. eclipse技巧总结
  3. MIME类型(JSP中)
  4. eclipse工程加入jquery.min.js报错:missing semicolon
  5. CentOS 5.8/6.7若干优化
  6. uva 11983 Weird Advertisement 扫描线
  7. VirtualBox虚拟vdi磁盘扩容
  8. PHP如何取出数组最后一个元素?
  9. python执行shell获取硬件参数写入mysql
  10. OC基础4:类和方法
  11. 关于在页面上执行sql语句
  12. iOS中Block介绍 基础
  13. 备注ocp_ORACLE专题网络
  14. 不想作死系列---virtualbox最小化安装centos6.5
  15. JavaScript - 平稳退化
  16. 使用CSS灵活的盒子
  17. Java爬虫_资源网站爬取实战
  18. (NO.00001)iOS游戏SpeedBoy Lite成形记(十三)
  19. Android--Menus
  20. jdk旧版本下载

热门文章

  1. Python ===if while for语句 以及一个小小网络爬虫实例
  2. How To Install Linux, Nginx, MySQL, PHP (LEMP) Stack on Debian 7
  3. [BZOJ1101][POI2007]Zap
  4. HTML快速入门3
  5. HDU 1707 简单模拟 Spring-outing Decision
  6. Django之表单字段的选填与后台界面的管理
  7. 【python】一个简单的贪婪爬虫
  8. Fresco 源码分析(二) Fresco客户端与服务端交互(2) Fresco.initializeDrawee()分析 续
  9. linux 小喇叭 没了
  10. 在Android中让Preference的宽度占满整个屏幕的宽度