Codeforces Round #302 (Div. 2) A. Set of Strings
来源:互联网 发布:mac机械键盘推荐 编辑:程序博客网 时间:2024/06/03 21:39
解:此题是一道字符串题,要求用指定数目的子串前后拼接构成一个整串,在拼接时需要保持每个子串首字母不一样,可以用大小为26的数组来标记每个子串的首字母,接下来再进行拼接判断即可。
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;const int maxm=1e3+10;char s[maxm];int vis[maxm];int vit[maxm];int main(){ int n; while(scanf("%d%s",&n,s)!=EOF) { memset(vis,0,sizeof(vis)); int cnt=0; int len=strlen(s); for(int i=0;i<len;i++) { if(cnt==n) break; if(!vis[s[i]-'0']) { vis[s[i]-'0']=1; vit[cnt++]=i; } } if(cnt!=n) { printf("NO\n"); continue; } printf("YES\n"); cnt=0; for(int i=0;i<len;i++) { if(i==vit[cnt]) { printf("\n"); cnt++; } printf("%c",s[i]); } printf("\n"); } return 0;}
0 0
- Codeforces Round #302 (Div. 2) A. Set of Strings
- Codeforces Round #302 (Div. 2) A. Set of Strings
- Codeforces Round #302 (Div. 2) A.Set of Strings&B.Sea and Islands&C.Writing Code
- Codeforces#302-A. Set of Strings-水题
- Codeforces Round #188 (Div. 2) B. Strings of Power
- Codeforces Round #293 (Div. 2)A. Vitaly and Strings
- Codeforces Round #293 (Div. 2) -- A. Vitaly and Strings
- Codeforces Round #293 (Div. 2)--A-- Vitaly and Strings - Painting
- CodeForces 544A Set of Strings
- Codeforces Round #302 (Div. 2) E. Remembering Strings(状压dp)
- A. Set of Strings
- Codeforces Round #260 (Div. 2) D. A Lot of Games
- Codeforces Round #363 (Div. 2)[A]Launch of Collider
- Codeforces Round #363 (Div. 2)A Launch of Collider
- Codeforces Round #363 (Div. 2) A. Launch of Collider
- Codeforces Round #363 (Div. 2) A. Launch of Collider
- Codeforces Round #371 (Div. 2) A. Meeting of Old Friends
- CF-Codeforces Round #392 (Div. 2)-A-Holiday Of Equality
- 孤华暗香的Python Spider,Updating
- ECMAScript 引用类型
- 把图片变为圆形的方法(QQ头像)
- 北大OJ1000
- QQl聊天消息
- Codeforces Round #302 (Div. 2) A. Set of Strings
- 如何在Linux中查看所有正在运行的进程
- 本地广播LocalBroadcastManager的好处
- servlet容器的URL映射知识
- 简易的 WebView 拦截事件等
- 创建用户报错ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value
- 北大OJ1001
- mysql参数调优
- Windows程序设计--创建第一个窗口