题目传送门

 /*
题意:一个字符串分割成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. 域名在微信朋友圈内分享需要ICP备案 杜绝不良信息传播

    就在刚刚,腾讯微信团队发布公告表示域名在朋友圈内分享需要ICP备案,杜绝打击不良互联网信息的传播.公告称根据互联网管理相关规定,即日起在微信朋友圈内分享的域名,请在2014年12月31日前完成ICP备 ...

  2. Linux内核之数据双链表

    导读 Linux 内核中自己实现了双向链表,可以在 include/linux/list.h 找到定义.我们将会首先从双向链表数据结构开始介绍内核里的数据结构.为什么?因为它在内核里使用的很广泛,你只 ...

  3. 入侵检测课设之Libnids开发包

    Libnids开发包介绍     Libnids是一个用于网络入侵检测开发的专业编程接口,它使用了Libpcap所以它具有捕获数据包的功能.同时,Libnids提供了TCP数据流重组功能,所以对于分析 ...

  4. [codeforces 293]A. Weird Game

    [codeforces 293]A. Weird Game 试题描述 Yaroslav, Andrey and Roman can play cubes for hours and hours. Bu ...

  5. poj1182(食物链)续

    意 动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形.A吃B, B吃C,C吃A. 现有N个动物,以1-N编号.每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种. 有人用 ...

  6. 写时复制技术(Copy-on-write)

    COW技术初窥:        在Linux程序中,fork()会产生一个和父进程完全相同的子进程,但子进程在此后多会exec系统调用,出于效率考虑,linux中引入了"写时复制" ...

  7. linux之eval用法(高级bash程序员的必修之技)

    1. eval command-line 其中command-line是在终端上键入的一条普通命令行.然而当在它前面放上eval时,其结果是shell在执行命令行之前扫描它两次.如: pipe=&qu ...

  8. Linux awk命令详解??????????(研究)

    http://blog.chinaunix.net/uid-25120309-id-3801250.html 一.  AWK 说明  awk是一种编程语言,用于在linux/unix下对文本和数据进行 ...

  9. 查看daemon使用技巧

    una ~ # ps -ef|egrep "*d$"或"[a-z]d"               //查看现有的服务器上都有哪些服务器进程.root 3509 ...

  10. vim技巧之快速进入引号删除至右引号前的内容

    参考:http://blog.chinaunix.net/uid-23381466-id-88482.html f'l ct' #fX,X可用任何字符,l表示向右移一位,ct'表示删除至引号前di'