水题 Codeforces Round #302 (Div. 2) A Set of Strings
2024-10-11 03:52:08
/*
题意:一个字符串分割成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 ;
}
最新文章
- [outlook]打开以后就自动进入安全模式的解决方法。Outlook start in safe mode.
- eclipse技巧总结
- MIME类型(JSP中)
- eclipse工程加入jquery.min.js报错:missing semicolon
- CentOS 5.8/6.7若干优化
- uva 11983 Weird Advertisement 扫描线
- VirtualBox虚拟vdi磁盘扩容
- PHP如何取出数组最后一个元素?
- python执行shell获取硬件参数写入mysql
- OC基础4:类和方法
- 关于在页面上执行sql语句
- iOS中Block介绍 基础
- 备注ocp_ORACLE专题网络
- 不想作死系列---virtualbox最小化安装centos6.5
- JavaScript - 平稳退化
- 使用CSS灵活的盒子
- Java爬虫_资源网站爬取实战
- (NO.00001)iOS游戏SpeedBoy Lite成形记(十三)
- Android--Menus
- jdk旧版本下载
热门文章
- Python ===if while for语句 以及一个小小网络爬虫实例
- How To Install Linux, Nginx, MySQL, PHP (LEMP) Stack on Debian 7
- [BZOJ1101][POI2007]Zap
- HTML快速入门3
- HDU 1707 简单模拟 Spring-outing Decision
- Django之表单字段的选填与后台界面的管理
- 【python】一个简单的贪婪爬虫
- Fresco 源码分析(二) Fresco客户端与服务端交互(2) Fresco.initializeDrawee()分析 续
- linux 小喇叭 没了
- 在Android中让Preference的宽度占满整个屏幕的宽度