水题 Codeforces Round #302 (Div. 2) A Set of Strings
/*
题意:一个字符串分割成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的更多相关文章
- 水题 Codeforces Round #299 (Div. 2) A. Tavas and Nafas
题目传送门 /* 很简单的水题,晚上累了,刷刷水题开心一下:) */ #include <bits/stdc++.h> using namespace std; ][] = {" ...
- 水题 Codeforces Round #304 (Div. 2) A. Soldier and Bananas
题目传送门 /* 水题:ans = (1+2+3+...+n) * k - n,开long long */ #include <cstdio> #include <algorithm ...
- 水题 Codeforces Round #303 (Div. 2) A. Toy Cars
题目传送门 /* 题意:5种情况对应对应第i或j辆车翻了没 水题:其实就看对角线的上半边就可以了,vis判断,可惜WA了一次 3: if both cars turned over during th ...
- 水题 Codeforces Round #286 (Div. 2) A Mr. Kitayuta's Gift
题目传送门 /* 水题:vector容器实现插入操作,暴力进行判断是否为回文串 */ #include <cstdio> #include <iostream> #includ ...
- 构造水题 Codeforces Round #206 (Div. 2) A. Vasya and Digital Root
题目传送门 /* 构造水题:对于0的多个位数的NO,对于位数太大的在后面补0,在9×k的范围内的平均的原则 */ #include <cstdio> #include <algori ...
- 水题 Codeforces Round #306 (Div. 2) A. Two Substrings
题目传送门 /* 水题:遍历一边先找AB,再BA,再遍历一边先找BA,再AB,两种情况满足一种就YES */ #include <cstdio> #include <iostream ...
- 水题 Codeforces Round #308 (Div. 2) A. Vanya and Table
题目传送门 /* 水题:读懂题目就能做 */ #include <cstdio> #include <iostream> #include <algorithm> ...
- 水题 Codeforces Round #307 (Div. 2) A. GukiZ and Contest
题目传送门 /* 水题:开个结构体,rk记录排名,相同的值有相同的排名 */ #include <cstdio> #include <cstring> #include < ...
- 水题 Codeforces Round #105 (Div. 2) B. Escape
题目传送门 /* 水题:这题唯一要注意的是要用double,princess可能在一个小时之内被dragon赶上 */ #include <cstdio> #include <alg ...
随机推荐
- DLL注入之SetWindowsHookEx
注:本文章转载自网络 函数功能:该函数将一个应用程序定义的挂钩处理过程安装到挂钩链中去,您可以通过安装挂钩处理过程来对系统的某些类型事件进行监控,这些事件与某个特定的线程或系统中的所有事件相关. 函数 ...
- android edittext 去边框
EditText的background属性设置为@null就搞定了:android:background="@null" style属性倒是可加可不加 附原文:@SlumberMa ...
- 新鲜出炉的百度js面试题
(文章是从我的个人主页上粘贴过来的,大家也可以访问我的主页 www.iwangzheng.com) 最近两位同学入职百度,带回来的笔试题基本上毫无悬念,不过有一个小题看到让人忍不住笑出声来,真的很无聊 ...
- 破解TP-Link路由-嗅探PPPoE拨号密码
如果你平时都使用路由器直接上网,那么你还记得你的宽带(ADSL)帐户名和密码吗?忘记密码后又该如何找回呢?别急,本文带你一同找回遗忘的ADSL密码.1.安全性较差的路由器(例如腾达的某些路由器):这里 ...
- win7安装apache或者php 5.7缺少vcruntime140.dll的问题
1.确定win7 系统是否是win7 sp1 版本.因为Visual C++ Redistributable for Visual Studio 2015 需要win7的sp1包的支持才能安装成功! ...
- web api 解决跨域的问题
web api 总是会遇到跨域的问题,今天我找到了如下方法解决跨域: 1: a:在配置文件中的 加上如下代码 <system.webServer> <httpProtocol> ...
- Linux system V
Sysvinit 的小结 Sysvinit 的优点是概念简单.Service 开发人员只需要编写启动和停止脚本,概念非常清楚:将 service 添加/删除到某个 runlevel 时,只需要执行一些 ...
- Linux 千万不要执行的10个命令
1. rm -rf 命令 rm -rf命令是删除文件夹及其内容最快的方式之一.仅仅一丁点的敲错或无知都可能导致不可恢复的系统崩坏.下列是一些rm 命令的选项. rm 命令在Linux下通常用来删除文件 ...
- 搭建自己的SIP服务器:开源sip服务器opensips的搭建及终端TwInkle的使用
搭建自己的SIP服务器:开源sip服务器opensips的搭建及终端TwInkle的使用 分类: linux编译相关2013-01-05 21:38 17983人阅读 评论(24) 收藏 举报 先下载 ...
- ldd查询命令或软件共享的函数库(动态)
<1> ldd - print shared library dependencies SYNOPSIS ldd [OPTION]... FILE... DESCRIPTION ldd p ...