【构造】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 ...
随机推荐
- 边绘边理解prototype跟__proto__
网上流传着一张讲解prototype跟__proto__关系的图,尽管他已经描绘的很清楚了,但对于初学者来说,江太公感觉还是过于纠结,于是起心重绘,让他们之间的关系更加明晰可理解,一方面出于分享目的, ...
- 往Layout中动态添加View
需要注意几个方法:基本上所有的方法参数单位是px 1.设置View的宽高: LinearLayout.LayoutParams params = new LinearLayout().LayoutPa ...
- javascript中的addEventListener与attchEvent
1.addEventListener 该方法用于向指定元素添加事件句柄 浏览器的支持情况为chrome1.0.ie9+.fireFox1.0.opera7.0 该方法包含三个参数event, func ...
- github删除文件夹
git rm -rf dirgit add .git commit -m 'remove dir'git push origin master //dir是要删除的文件夹路径
- SQL语句语法简介
SQL命令一般分为DQL.DML.DDL几类: DQL:数据查询语句,基本就是SELECT查询命令,用于数据查询 DML:Data Manipulation Language的简称,即数据操纵语言,主 ...
- FAN54015 充電電流 軟硬體設定
Ex1: Vrsense 選 37.4 mV --- 在第二張圖 Rsense 選 50 mΩ --- 在第三張圖 37.4 / 50 = 748 mA Ex2: Vrsense 選 44.2 mV ...
- [device tree] interrupt mapping example
This is for Devicetree Specification Release 0.1 Interrupt Mapping Example p19 在講解前,先帶進一些 PCI 的基礎觀念 ...
- [New Learn]被嫌弃的app的一生
1.简介 为什么叫被嫌弃的app的一生?致敬电影<被嫌弃的松子的一生>. 自学IOS东一锄西一镐的总感觉没有一个总的概念,还是多看看官网吧,先看一下一个app的整个生命周期,本文主要是翻译 ...
- [ python ] 类的组合
首先,使用面向对象是一个人狗大战的实例: class Person: def __init__(self, name, hp, aggr, sex): self.name = name self.hp ...
- Flask 知识总结
阅读目录 第一篇:Flask基础知识介绍 第二篇:Flask扩展小结 第三篇:Flask 配置文件 第四篇:ORM.MySQL数据库连接池 第五篇:单例模式.蓝图Blueprint 第六篇:SQLAL ...