【构造】Codeforces Round #405 (rated, Div. 1, based on VK Cup 2017 Round 1) A. Bear and Different Names
如果某个位置i是Y,直接直到i+m-1为止填上新的数字。
如果是N,直接把a[i+m-1]填和a[i]相同即可,这样不影响其他段的答案。
当然如果前面没有过Y的话,都填上0就行了。
#include<cstdio>
#include<string>
#include<iostream>
using namespace std;
int n,m,a[60],e;
string ma[60];
int main(){
// freopen("a.in","r",stdin);
char op[10];
for(int i=1;i<=26;++i){
ma[i]+=(i+'A'-1);
}
for(int i=27;i<=50;++i){
ma[i]+=(i-27+'A');
ma[i]+='a';
}
ma[0]="Bb";
scanf("%d%d",&n,&m);
for(int i=1,j=1;i<=n-m+1;++i){
scanf("%s",op);
if(op[0]=='Y'){
for(;j<=i+m-1;++j){
a[j]=e++;
}
}
else{
a[j++]=a[i];
}
}
for(int i=1;i<n;++i){
cout<<ma[a[i]]<<' ';
}
cout<<ma[a[n]]<<endl;
return 0;
}
【构造】Codeforces Round #405 (rated, Div. 1, based on VK Cup 2017 Round 1) A. Bear and Different Names的更多相关文章
- Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) 菜鸡只会ABC!
Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) 全场题解 菜鸡只会A+B+C,呈上题解: A. Bear and ...
- Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) C. Bear and Different Names 贪心
C. Bear and Different Names 题目连接: http://codeforces.com/contest/791/problem/C Description In the arm ...
- Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1)A B C 水 并查集 思路
A. Bear and Big Brother time limit per test 1 second memory limit per test 256 megabytes input stand ...
- Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) B - Bear and Friendship Condition 水题
B. Bear and Friendship Condition 题目连接: http://codeforces.com/contest/791/problem/B Description Bear ...
- Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1)
A 模拟 B 发现对于每个连通块,只有为完全图才成立,然后就dfs C 构造 想了20分钟才会,一开始想偏了,以为要利用相邻NO YES的关系再枚举,其实不难.. 考虑对于顺序枚举每一个NO/YES, ...
- 【树形dp】Codeforces Round #405 (rated, Div. 1, based on VK Cup 2017 Round 1) B. Bear and Tree Jumps
我们要统计的答案是sigma([L/K]),L为路径的长度,中括号表示上取整. [L/K]化简一下就是(L+f(L,K))/K,f(L,K)表示长度为L的路径要想达到K的整数倍,还要加上多少. 于是, ...
- Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) C
Description In the army, it isn't easy to form a group of soldiers that will be effective on the bat ...
- Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) E
Description Bear Limak prepares problems for a programming competition. Of course, it would be unpro ...
- Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) D
Description A tree is an undirected connected graph without cycles. The distance between two vertice ...
随机推荐
- Java案例之随机验证码功能实现
实现的功能比较简单,就是随机产生了四个字符然后输出.效果图如下,下面我会详细说一下实现这个功能用到了那些知识点,并且会把 这些知识点详细的介绍出来.哈哈 ,大神勿喷,对于初学Java的人帮助应该蛮大的 ...
- 一个基于时间注入的perl小脚本
use strict; use warnings; use LWP::Simple; my %table_and_leng; ;;$count++){ #print "Test Table: ...
- (转)opencv 代替caffe.io.load_image
self.net.blobs[, , self.image_resize, self.image_resize) #image = caffe.io.load_image(image_file) im ...
- 启动另一个activity
1. 只负责启动 Intent intent = new Intent(mContext, BookOrderActivity.class); Bundle mEmployeeBundle = new ...
- MyEclipse部署项目报"Add Deployment". Invalid Subscription Level - Discontinuing this MyEclipse
"Add Deployment". Invalid Subscription Level - Discontinuing this MyEclipse 猜测应该是MyEclipse ...
- https配置注意细节
直接将阿里云https的ca配置配置好之后如果不通的话很有可能是防火墙原因造成的,还有就是nginx要用1.10以上版本的
- Jmeter性能测试示例
这次成功做了一个jmeter借口性能测试的简单测试示例,分享一下给大家. jmeter作为一个简单的开源工具,基于java的性能测试工具,使用起来很简单. 也可以作为二次开发,复杂的情形可以自己写代码 ...
- 微软推出ASP.NET Core 2.0,并支持更新Visual Studio 2017
微软推出ASP.NET Core 2.0的一般可用性,并发布.NET Core 2.0.该公司还推出了其旗舰集成开发环境(IDE)的更新:Visual Studio 2017版本15.3和Visual ...
- 我是如何向老婆解释MapReduce的?
转载自:<我是如何向老婆解释MapReduce的?> 昨天,我在Xebia印度办公室发表了一个关于MapReduce的演说.演说进行得很顺利,听众们都能够理解MapReduce的概念(根据 ...
- Django Ajax学习二之csrf跨站请求伪造
方式1 $.ajaxSetup({ data: {csrfmiddlewaretoken: '{{ csrf_token }}' }, }); 方式2 # html文件from表单中<form& ...