803E - Roma and Poker

思路:

  赢或输或者平的序列;

  赢和平的差的绝对值不得超过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的更多相关文章

  1. AC日记——Dynamic Problem Scoring codeforces 807d

    Dynamic Problem Scoring 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <io ...

  2. 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 ...

  3. AC日记——Sagheer, the Hausmeister codeforces 812b

    812B - Sagheer, the Hausmeister 思路: 搜索: 代码: #include <cstdio> #include <cstring> #includ ...

  4. AC日记——Sagheer and Crossroads codeforces 812a

    812A - Sagheer and Crossroads 思路: 模拟: 代码: #include <cstdio> #include <cstring> #include ...

  5. AC日记——Is it rated? codeforces 807a

    Is it rated? 思路: 水题: 代码: #include <cstdio> #include <cstring> using namespace std; ],b[] ...

  6. Ac日记——Distances to Zero codeforces 803b

    803B - Distances to Zero 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <i ...

  7. AC日记——Mice and Holes codeforces 797f

    797F - Mice and Holes 思路: XXYXX: 代码: #include <cmath> #include <cstdio> #include <cst ...

  8. AC日记——Periodic RMQ Problem codeforces 803G

    G - Periodic RMQ Problem 思路: 题目给一段序列,然后序列复制很多次: 维护序列很多次后的性质: 线段树动态开点: 来,上代码: #include <cstdio> ...

  9. AC日记——Andryusha and Socks Codeforces 780a

    A. Andryusha and Socks time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

随机推荐

  1. 数据库路由中间件MyCat - 源代码篇(2)

    此文已由作者张镐薪授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 2. 前端连接建立与认证 Title:MySql连接建立以及认证过程client->MySql:1.T ...

  2. 用scrapy数据抓取实践

    本文来自网易云社区 作者:沈高峰 数据分析中需要用到的不少数据都是需要进行抓取的,并且需要对抓取的数据进行解析之后存入数据库.scrapy是一个强大的爬虫框架,本文简单介绍下使用scrapy进行垂直抓 ...

  3. TO_CHAR 和 TO_DATE的一些用法总结

    对于初学者来说,日期处理那快一向是问题的集中地.今天刚刚看了个案例,将的就是ORACLE日期处理中的错误,其关键原因,就是TO_CHAR 和TO_DATE的用法不清晰,,事实上,这两个东西也特别容易混 ...

  4. appium-desktop 环境搭建 Java版

    用的是appium-desktop1.8.1,testng6.11,java-client6.1.0,selenium-java3.13.0 1.下载逍遥模拟器,装好app 2.下载adb,用adb连 ...

  5. Entity Framework(三)---FluentAPI和增删查改

    一.FluentAPI: 1.基本配置: namespace ConsoleApp14.ModelConfig { public class PersonConfig: EntityTypeConfi ...

  6. 椭圆曲线加密和rsa对比

    最近在导师的要求下接手了基于欧洲标准的车联网项目中的安全层,需要学习密码学,以及网络安全的相关内容,这里做一个总结 引用的大部分内容为一个西安的大佬(哈哈我老家也是西安的),大佬主页:https:// ...

  7. c++知识点总结--new的一些用法

    new operator 将对象产生与heap,不但分配内存而且为该对象调用一个constructor   operator new只是分配内存,没有constructor被调用 有个一个特殊版本,称 ...

  8. springmvc maven搭建一

    一.标题:使用maven搭建一个简单的web工程 二.涉及工具:Eclipse.maven.tomcat8.0.jdk1.8 三.操作: 完善项目:增加src/main/java,src/test/r ...

  9. 第十一篇:MySQL基础

    本篇内容 MySQL概述 MySQL安装 MySQL库增.删.改.查 MySQL表增.删.改.查 MySQL表记录增.删.改.查 一. MySQL概述 MySQL是一个关系型数据库管理系统,由瑞典 M ...

  10. Hibernate的注释该如何使用?每一个注释代表什么意思?

    出自:java快快飞 原文地址:http://blog.sina.com.cn/s/blog_697b968901016s31.html Hibernate的注释该如何使用?每一个注释代表什么意思? ...