AC日记——Roma and Poker codeforces 803e
思路:
赢或输或者平的序列;
赢和平的差的绝对值不得超过k;
结束时差的绝对值必须为k;
当“?”时可以自己决定为什么状态;
输出最终序列或者NO;
dp(随便搞搞);
来,上代码:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; int n,k,dp[][],m; char ch[]; int main()
{
cin>>n>>k;
cin>>ch+;
m=k-;dp[][m+]=true;
for(int i=;i<n;i++)
{
if(ch[i]=='W') for(int j=;j<=m*+;j++) dp[i][j]=dp[i-][j-];
else if(ch[i]=='L') for(int j=;j<m*+;j++) dp[i][j]=dp[i-][j+];
else if(ch[i]=='D') for(int j=;j<=m*+;j++) dp[i][j]=dp[i-][j];
else for(int j=;j<=m*+;j++) dp[i][j]=(dp[i-][j-]||dp[i-][j]||dp[i-][j+]);
}
if(ch[n]=='W') dp[n][*m+]=dp[n-][*m+];
else if(ch[n]=='L') dp[n][]=dp[n-][];
else if(ch[n]=='D') ;
else dp[n][]=dp[n-][],dp[n][m*+]=dp[n-][m*+];
if(!dp[n][]&&!dp[n][m*+]) cout<<"NO";
else
{
int now;
if(dp[n][m*+]) now=m*+;
else now=;
for(int i=n;i>;i--)
{
if(ch[i]=='L') now++;
else if(ch[i]=='W') now--;
else if(ch[i]=='D') now=now;
else
{
if(dp[i-][now+]) now++,ch[i]='L';
else if(dp[i-][now]) ch[i]='D';
else if(dp[i-][now-]) now--,ch[i]='W';
}
}
cout<<ch+;
}
return ;
}
AC日记——Roma and Poker codeforces 803e的更多相关文章
- AC日记——Dynamic Problem Scoring codeforces 807d
Dynamic Problem Scoring 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <io ...
- AC日记——Sign on Fence Codeforces 484e
E. Sign on Fence time limit per test 4 seconds memory limit per test 256 megabytes input standard in ...
- AC日记——Sagheer, the Hausmeister codeforces 812b
812B - Sagheer, the Hausmeister 思路: 搜索: 代码: #include <cstdio> #include <cstring> #includ ...
- AC日记——Sagheer and Crossroads codeforces 812a
812A - Sagheer and Crossroads 思路: 模拟: 代码: #include <cstdio> #include <cstring> #include ...
- AC日记——Is it rated? codeforces 807a
Is it rated? 思路: 水题: 代码: #include <cstdio> #include <cstring> using namespace std; ],b[] ...
- Ac日记——Distances to Zero codeforces 803b
803B - Distances to Zero 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <i ...
- AC日记——Mice and Holes codeforces 797f
797F - Mice and Holes 思路: XXYXX: 代码: #include <cmath> #include <cstdio> #include <cst ...
- AC日记——Periodic RMQ Problem codeforces 803G
G - Periodic RMQ Problem 思路: 题目给一段序列,然后序列复制很多次: 维护序列很多次后的性质: 线段树动态开点: 来,上代码: #include <cstdio> ...
- AC日记——Andryusha and Socks Codeforces 780a
A. Andryusha and Socks time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
随机推荐
- form表单提交和重置小结
1. input标签 1.1>input[type=submit] <form name="form" method="post" action=& ...
- Spark Streaming实例
Spark Streaming实例分析 2015-02-02 21:00 4343人阅读 评论(0) 收藏 举报 分类: spark(11) 转载地址:http://www.aboutyun.co ...
- javascript类式继承模式#2——借用构造函数
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 《Cracking the Coding Interview》——第17章:普通题——题目2
2014-04-28 22:05 题目:写个程序判断三连棋哪一方赢了. 解法:三个相同的棋子连成一条横线,竖线或者对角线就判断为赢了. 代码: // 17.2 Write an algorithm t ...
- DOS程序员手册(九)
第14章参考手册概述 本书余下的章节将向读者们介绍BIOS.DOS各种各样API函数和服务,作为一名程 序员,了解和掌握这些知识是很有好处的.在所介绍的参考手册中,每部手册都汇集了大 量的资源 ...
- loadrunner 欺骗ip设置
工具准备:loadrunner12,windows 10 ip欺骗=ip wizard 前提条件:本机IP地址为固定地址,不是自动获取的地址 方法: 1.管理员身份打开cmd 2.输入命令:confi ...
- iframe 如何让它展现内容自适应高度
引用: <iframe id="ifm1" runat="server" src="/comment/page1?id=@productId&q ...
- echarts 柱状图下钻功能
var drillDown = { getOption : function () { var option = null; option = { title: { text: ' ...
- Python数据分析-Pandas(Series与DataFrame)
Pandas介绍: pandas是一个强大的Python数据分析的工具包,是基于NumPy构建的. Pandas的主要功能: 1)具备对其功能的数据结构DataFrame.Series 2)集成时间序 ...
- [部署开发环境][1 vagrant] vagrant部署开发环境--安装vagrant
# 安装教程 # 安装vagrant 教程 # 准备 - windows操作系统 - VirtualBox---Win, - vagrant_1.9.3.msi - 镜像文件https://atlas ...