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 ...
随机推荐
- Django的Field(字段)
字段 1.models.AutoField 自增列 = int(11) 如果没有的话,默认会生成一个名称为 id 的列,如果要显示的自定义一个自增列,必须将给列设置为主键 primary_key=Tr ...
- SparkSteaming中直连与receiver两种方式的区别
SparkStreaming的Receiver方式和直连方式有什么区别? Receiver接收固定时间间隔的数据(放在内存中的),使用高级API,自动维护偏移量,达到固定的时间才去进行处理,效率低并且 ...
- 剑指Offer - 九度1523 - 从上往下打印二叉树
剑指Offer - 九度1523 - 从上往下打印二叉树2013-12-01 00:35 题目描述: 从上往下打印出二叉树的每个节点,同层节点从左至右打印. 输入: 输入可能包含多个测试样例,输入以E ...
- 利用Xtrabackup搭建GTID主从复制(一主一从)
Preface I've been demonstrated how to implement a master-slave structure using mysqldump in ...
- 解决idea无法下载插件的问题
分析原因: 使用了 https 协议下载而导致的问题. 解决办法: 找到 File -> Settings -> Appearance & Behavior -> Syste ...
- ASP.NET Core [4]: Authentication(笔记)
原文连接:http://www.cnblogs.com/RainingNight/p/authentication-in-asp-net-core.html 在现代应用程序中,认证已不再是简单的将用户 ...
- HDU 4741 Save Labman No.004 ( 三维计算几何 空间异面直线距离 )
空间异面直线的距离直接套模板. 求交点:求出两条直线的公共法向量,其中一条直线与法向量构成的平面 与 另一条直线 的交点即可.还是套模板o(╯□╰)o 1.不会有两条线平行的情况. 2.两条直线可能相 ...
- XML快速入门
XML是什么 Extensible Markup Language 自定义标签: 用来传输数据: 可扩展标记语言,是一种类似超文本标记语言的标记语言. 与HTML的比较: 1.不是用来替代HTML的: ...
- 转换 nvarchar 值 '2013071200000578' 时溢出了整数列
sqlserver 把一个nvarchar 与 int 类型 拼接 会自动转换 INT 做运算,nvarchar 类型有16位 转换失败 只能 str(int) 转换成 字符型 进行拼接 (sqls ...
- php记日志
就是把log追加到文件中 用到了一个方法 file_put_contents <?php file_put_contents('a',date('Y m d h:i:s').' some tex ...