题目传送门

 /*
题意:一个字符串分割成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 ;
}

水题 Codeforces Round #302 (Div. 2) A Set of Strings的更多相关文章

  1. 水题 Codeforces Round #299 (Div. 2) A. Tavas and Nafas

    题目传送门 /* 很简单的水题,晚上累了,刷刷水题开心一下:) */ #include <bits/stdc++.h> using namespace std; ][] = {" ...

  2. 水题 Codeforces Round #304 (Div. 2) A. Soldier and Bananas

    题目传送门 /* 水题:ans = (1+2+3+...+n) * k - n,开long long */ #include <cstdio> #include <algorithm ...

  3. 水题 Codeforces Round #303 (Div. 2) A. Toy Cars

    题目传送门 /* 题意:5种情况对应对应第i或j辆车翻了没 水题:其实就看对角线的上半边就可以了,vis判断,可惜WA了一次 3: if both cars turned over during th ...

  4. 水题 Codeforces Round #286 (Div. 2) A Mr. Kitayuta's Gift

    题目传送门 /* 水题:vector容器实现插入操作,暴力进行判断是否为回文串 */ #include <cstdio> #include <iostream> #includ ...

  5. 构造水题 Codeforces Round #206 (Div. 2) A. Vasya and Digital Root

    题目传送门 /* 构造水题:对于0的多个位数的NO,对于位数太大的在后面补0,在9×k的范围内的平均的原则 */ #include <cstdio> #include <algori ...

  6. 水题 Codeforces Round #306 (Div. 2) A. Two Substrings

    题目传送门 /* 水题:遍历一边先找AB,再BA,再遍历一边先找BA,再AB,两种情况满足一种就YES */ #include <cstdio> #include <iostream ...

  7. 水题 Codeforces Round #308 (Div. 2) A. Vanya and Table

    题目传送门 /* 水题:读懂题目就能做 */ #include <cstdio> #include <iostream> #include <algorithm> ...

  8. 水题 Codeforces Round #307 (Div. 2) A. GukiZ and Contest

    题目传送门 /* 水题:开个结构体,rk记录排名,相同的值有相同的排名 */ #include <cstdio> #include <cstring> #include < ...

  9. 水题 Codeforces Round #105 (Div. 2) B. Escape

    题目传送门 /* 水题:这题唯一要注意的是要用double,princess可能在一个小时之内被dragon赶上 */ #include <cstdio> #include <alg ...

随机推荐

  1. Charm Bracelet

    Charm Bracelet Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Subm ...

  2. Html form 表单提交前验证

    可以使用form表单的onsubmit方法,在提交表单之前,对表单或者网页中的数据进行检验. onsubmit指定的方法返回true,则提交数据:返回false不提交数据. 直接看下面的代码: 1 & ...

  3. 【SpringMVC】SpringMVC系列8之Servlet API 作为入参

    8.Servlet API 作为入参 8.1.概述 MVC 的 Handler 方法可以接受哪些 ServletAPI 类型的参数: HttpServletRequest HttpServletRes ...

  4. Linux匿名管道与命名管道

    http://blog.chinaunix.net/uid-26000296-id-3408970.html /* * \File * main.c * \Descript * father-proc ...

  5. 70 数组的Kmin算法和二叉搜索树的Kmin算法对比

    [本文链接] http://www.cnblogs.com/hellogiser/p/kmin-of-array-vs-kmin-of-bst.html [分析] 数组的Kmin算法和二叉搜索树的Km ...

  6. 【转】javax.net.ssl.SSLHandshakeException(Cas导入证书)

    本文转自:http://my.oschina.net/laiwanshan/blog/159057 一.报错: javax.net.ssl.SSLHandshakeException 二.原因分析:C ...

  7. HttpHandler简介

    新建的一般处理程序后缀为.ashx,一般会另外新建一个后缀为.ashx.cs的文件,其实所有的代码都写在.ashx.cs里面,只是微软帮我们做了一个傻瓜化的转换新建的一般处理程序,如:Text1,它就 ...

  8. 调试工具GDB详解

    1 简介 2 生成调试信息 3 启动GDB 的方法 4 程序运行上下文 4.1 程序运行参数 4.2 工作目录 4.3 程序的输入输出 5 设置断点 5.1 简单断点 5.2 多文件设置断点 5.3 ...

  9. jdk

    mkdir java mv jdk1.7.0_71/ java/ [root@centos02 src]# java -version java version "1.7.0_71" ...

  10. XtraScrollableControl 滚动条控件随鼠标滚动

    using System; using System.Windows.Forms; using DevExpress.XtraEditors; namespace WindowsFormsApplic ...