【构造】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 ...
随机推荐
- python初步学习-pycharm使用
Pycharm简介 PyCharm是一种Python IDE,带有一整套可以帮助用户在使用Python语言开发时提高其效率的工具,比如调试.语法高亮.Project管理.代码跳转.智能提示.自动完成. ...
- st2-045漏洞利用poc
use LWP::UserAgent; undef $/; ){print "Use:poc.pl http://target/index.action\n";exit;} my ...
- 通过or注入py脚本
代码思路 1.主要还是参考了别人的代码,确实自己写的和别人写的出路很大,主要归咎还是自己代码能力待提高吧. 2.将功能集合成一个函数,然后通过*args这个小技巧去调用.函数的参数不是argv的值,但 ...
- 以下suse11.3x64可以安装pycrypto-2.6.1
rpm -qa adaptec-firmware-1.35-2.15.4gnome-menus-branding-SLED-11.1-14.26man-pages-3.15-2.23.1crackli ...
- 直接在注册DB服务的时候,做beforeQuery事件监听
- System V共享内存介绍
(一)简单概念 共享内存作为一种进程间通信的方式,其相较于其他进程间通信方式而言最大的优点就是数据传输速率快.其内部实现的方式采用了Linux进程地址空间中的mmap文件映射区,将文件内容直接映射到各 ...
- 压缩LDF档
--压缩LDF档 USE VoucherServer; GO -- Truncate the log by changing the database recovery model to SIMPLE ...
- springboot在不同环境下进行不同的配置
原文链接:http://www.cnblogs.com/java-zhao/p/5469183.html 不同的环境设置一个配置文件,例如:dev(开发)环境下的配置设置在application-de ...
- vim常用命令(复习版)(转)
原文链接:http://blog.csdn.net/love__coder/article/details/6739670 1.光标移动 上:k 下:j 左:l 『字母L小写』 右:h 上一行行首:- ...
- C#多线程编程之:集合类中Synchronized方法与SyncRoot属性原理分析
我们知道,在.net的一些集合类型中,譬如Hashtable和ArrayList,都有Synchronized静态方法和SyncRoot属性,他们之间有联系吗?我怎么才能用好他们呢? 以Hashtab ...