【构造】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----通过Socket实现简单的ssh客户端
光只是简单的发消息.收消息没意思,干点正事,可以做一个极简版的ssh,就是客户端连接上服务器后,让服务器执行命令,并返回结果给客户端. #ssh_client.py import socket cli ...
- python进行机器学习(二)之特征选择
毫无疑问,解决一个问题最重要的是恰当选取特征.甚至创造特征的能力,这叫做特征选取和特征工程.对于特征选取工作,我个人认为分为两个方面: 1)利用python中已有的算法进行特征选取. 2)人为分析各个 ...
- linux系统环境 ——(四)
默认有6个命令交互通道和一个图形界面交互通道,默认进入到的是图形界面通道 命令交互模式切换:ctrl+alt+f1---f6 图形交互界面 ctrl+alt+f7 1.图形界面交互模式 - termi ...
- aptitude约等于apt-get的工具
如题,与之不同的是其会将依赖的程序也给删除. https://baike.baidu.com/item/aptitude/6849487?fr=aladdin 以下是一些常用 aptitude命令,仅 ...
- 【Matlab】绘制饼状统计图
a=tabulate(b); % b为需要绘制饼图的原始数据列,生成新的一个矩阵a label={'1','2','3'} % 设定饼图每块扇形代表的内容 percent=num2str(a(:,3) ...
- Vuex 基本概念
Vuex 是一个专为 Vue.js 应用程序开发的状态管理模式.它采用集中式存储管理应用的所有组件的状态,并以相应的规则保证状态以一种可预测的方式发生变化. 每一个 Vuex 应用的核心就是 stor ...
- MongoDB的安装配置、基本操作及Perl操作MongoDB
MongoDB的安装配置.基本操作及Perl操作MongoDB http://www.myhack58.com/Article/60/63/2014/42353.htm
- 2017多校第8场 HDU 6138 Fleet of the Eternal Throne 思维,暴力
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6138 题意:给了初始区间[-1,1],然后有一些操作,可以r加上一个数,l减掉一个数,或者同时操作,问 ...
- 升级OS10.11系统后 Xcode6.4的变化少了个按钮 could not launch “Xcode” Xcode 插件安装
升级OS10.11系统后 Xcode6.4的变化少了个按钮 could not launch “Xcode” Xcode 插件安装 A: 升级10.11后Xcode 左上角模拟器选择菜单不在了 ...
- Winform利用委托进行窗体间的传值
在form1.cs中 1.委托的定义 //定义一个委托 public delegate void AddUsrEventHandler(object sender, AddUsrEventHandle ...