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 ...
随机推荐
- Android学习笔记(四)之碎片化Fragment实现仿人人客户端的侧边栏
其实一种好的UI布局,可以使用户感到更加的亲切与方便.最近非常流行的莫过于侧边栏了,其实我也做过很多侧边栏的应用,但是那些侧边栏的使用我 都不是很满意,现在重新整理,重新写了一个相对来说我比较满意的侧 ...
- 《Cracking the Coding Interview》——第16章:线程与锁——题目6
2014-04-27 20:25 题目:关于java中标有synchronized的成员方法? 解法:这代表同一个对象实例的synchronized方法不能被多个线程同时调用.注意有这么多个地方都加粗 ...
- USACO Section1.2 Dual Palindromes 解题报告
dualpal解题报告 —— icedream61 博客园(转载请注明出处)-------------------------------------------------------------- ...
- 【Radial Basis Function Network】林轩田机器学习技法
这节课主要讲述了RBF这类的神经网络+Kmeans聚类算法,以及二者的结合使用. 首先回归的了Gaussian SVM这个模型: 其中的Gaussian kernel又叫做Radial Basis F ...
- iOS笔记056 - UI总结02
九宫格布局 UICollectionViewController 创建控制器一定要指定默认的布局样式. // 加载一个九宫格布局的控制器,必须指定布局样式 UICollectionViewFlowLa ...
- 关于JavaScript设计模式的学习(二)
第二部分来了,是关于结构型的,同样的,还是在简书中,GitHub上也有代码示例和详细注释 简书:http://www.jianshu.com/p/face1be4b846 github:https:/ ...
- Python 爬虫-豆瓣读书
import requests from bs4 import BeautifulSoup def parse_html(num): headers = { 'User-Agent': 'Mozill ...
- postman与charles的结合使用
1.准备charles环境 Charles端口一般配置的为8888,不知道怎么配置详见charles文档 打开charles,发现访问浏览器任意页面都是失败. 在浏览器的高级设置中设置代理服务器,以火 ...
- 条件随机场(Conditional random field)
条件随机场真是把我给折磨坏了啊,本以为一本小小的<统计学习方法>攻坚剩下最后一章,心情还是十分愉悦的,打算一口气把它看完,结果真正啃起来真是无比的艰难啊,每一句对我都好像是天书一般,怎么这 ...
- stuff使用感悟
select ),t2.CityId) from t t2 where not exists( from Web_UserCity uc where UserName='user001' and uc ...