当前位置:网站首页>Educational Codeforces Round 20 E. Roma and Poker
Educational Codeforces Round 20 E. Roma and Poker
2022-06-09 05:56:00 【No toast】
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define eps 1e-2
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;
const int maxn = 1e3+2;
const int INF = 1<<30;
const int mod = 1e9+7;
const int M=1e3+10;
int n,k,dp[maxn][M*2+10],pre[maxn][M*2+10];
char ch[maxn];
std::vector<char> res;
bool check(int pos){
// cout<<pos<<endl;
int fl=0;
int now=n,pr=pre[now][pos];
while(now){
// cout<<pr<<" "<<pos<<endl;
if(ch[now]=='?'){
if(pr<pos) res.push_back('W');
else if(pr>pos) res.push_back('L');
else res.push_back('D');
}else res.push_back(ch[now]);
--now;pos=pr;pr=pre[now][pr];fl=1;
// cout<<now<<endl;
}
return 1;
}
void solve(){
scanf("%d%d",&n,&k);cin>>ch+1;
dp[0][M]=1;
for(int i=1;i<=n;i++){
for(int j=1-k;j<=k-1;j++){
if(dp[i-1][j+M]==0) continue;
if(ch[i]=='L'||ch[i]=='?'){
dp[i][j+M-1]=1;
pre[i][j+M-1]=j+M;
}
if(ch[i]=='W'||ch[i]=='?'){
dp[i][j+M+1]=1;
pre[i][j+M+1]=j+M;
}
if(ch[i]=='D'||ch[i]=='?'){
dp[i][j+M]=1;
pre[i][j+M]=j+M;
}
}
}
// cout<<dp[n][M+k]<<" "<<dp[n][M-k]<<endl;
if(dp[n][M+k]&&check(M+k)){
for(int i=res.size()-1;i>=0;i--) cout<<res[i];cout<<endl;}
else if(dp[n][M-k]&&check(M-k)){
for(int i=res.size()-1;i>=0;i--) cout<<res[i];cout<<endl;}
else{
cout<<"NO"<<endl;
}
// if(==-1) {cout<<"NO"<<endl;return;}
return;
}
int main()
{
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
// ios::sync_with_stdio(false);
int t = 1;
//scanf("%d",&t);
while(t--){
// printf("Case %d: ",cas++);
solve();
}
return 0;
}
边栏推荐
- MySQL tuning - overview of MySQL parameters and status
- Educational Codeforces Round 20 E. Roma and Poker
- Synchronized detailed parsing
- Practical guide to GStreamer application development (II)
- Thread interrupted detailed parsing
- Topic26——11. Container with the most water
- synchronized 详细解析
- Matlab - polynomial and function
- MySql中事务详细理解学习(事务管理、事务隔离级别、事务传播机制)
- Mysql 添加字段或者创建表SQL语句
猜你喜欢

传输介质双绞线和光纤及二进制

ThreadLocal parsing

Wireshark图解TCP三次握手与四次挥手

Complete webrtc video recording in five minutes

Gstreamer应用开发实战指南(一)

Painstakingly wrote a detailed MySQL tutorial of 24K words in three days, three nights

Thread interrupted detailed parsing

MVCC多版本控制
![Tricks | [trick6] learning rate adjustment strategy of yolov5 (one cycle policy, cosine annealing, etc.)](/img/e8/d11adffb784b0875c69f6fe5a32b63.png)
Tricks | [trick6] learning rate adjustment strategy of yolov5 (one cycle policy, cosine annealing, etc.)

JVM basic theory.
随机推荐
Google Colab 使用小贴士
Time stamp verification code signing method for code signing certificate
Tensorflow introductory tutorial 02 basic concepts of tensorflow (data flow graph, tensor, tensorboard)
New and old versions of Minio tool classes and deployment documents
测试和线程
Seaweedfs client adapts to the higher version of seaweedfs service
Jdbc-dbutils
DBeaver导出查询数据sql文件
MySql使用模糊查询中文时查询语句出现乱码的解决
Data consanguinity use case and extension practice
ThreadLocal parsing
Mysql 添加字段或者创建表SQL语句
Esmascript 6.0 advanced
synchronized 详细解析
Data inconsistency between the reids cache and the database, cache expiration and deletion
SSL证书安装后网站还是显示不安全
MySql中事务详细理解学习(事务管理、事务隔离级别、事务传播机制)
MySQL add field or create table SQL statement
Go language tutorial 01 go tools +go syntax +go module
Educational Codeforces Round 20 E. Roma and Poker