Codeforces Round #619 (Div. 2)D(模拟)
先把一种最长路线记录下来,根据k的大小存到ans中相应的答案再输出
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
vector<char>vv;
vector<pair<int,char>>ans;
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,m,k;
cin>>n>>m>>k;
int mx=*m*n-*m-*n;
if(k>mx){
cout<<"NO\n";
return ;
}
for(int i=;i<n;++i)
vv.emplace_back('D');
for(int i=;i<m;++i)
vv.emplace_back('R');
for(int j=m;j>;--j){
for(int i=n;i>;--i)
vv.emplace_back('U');
for(int i=;i<n;++i)
vv.emplace_back('D');
vv.emplace_back('L');
}
for(int i=n-;i>=;--i){
vv.emplace_back('U');
for(int j=;j<m;++j)
vv.emplace_back('R');
for(int j=m;j>;--j)
vv.emplace_back('L');
}
char pos=vv[];
int cnt=;
for(int i=;i<k;++i)
if(pos==vv[i])
++cnt;
else{
ans.push_back({cnt,pos});
pos=vv[i];
cnt=;
}
if(cnt)
ans.push_back({cnt,pos});
cout<<"YES\n";
cout<<ans.size()<<"\n";
for(auto it:ans)
cout<<it.first<<" "<<it.second<<"\n";
return ;
}
Codeforces Round #619 (Div. 2)D(模拟)的更多相关文章
- Codeforces Round #249 (Div. 2) (模拟)
C. Cardiogram time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Codeforces Round #366 (Div. 2) C 模拟queue
C. Thor time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu ...
- 题解——Codeforces Round #508 (Div. 2) T1 (模拟)
依照题意暴力模拟即可A掉 #include <cstdio> #include <algorithm> #include <cstring> #include &l ...
- Codeforces Round #281 (Div. 2) B 模拟
B. Vasya and Wrestling time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- Codeforces Round #281 (Div. 2) A 模拟
A. Vasya and Football time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- Codeforces Round #362 (Div. 2) B 模拟
B. Barnicle time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...
- Codeforces Round #619 (Div. 2)E思维+二维RMQ
题:https://codeforces.com/contest/1301/problem/E 题意:给个n*m的图形,q个询问,每次询问问询问区间最大的合法logo的面积是多少 分析:由于logo是 ...
- Codeforces Round #357 (Div. 2) 优先队列+模拟
C. Heap Operations time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces Round #619 (Div. 2) A~D题解
最近网课也开始了,牛客上一堆比赛题目也没补,所以就D题后面的也懒得补了 A.Three String 水题 #include <cstdio> #include <cstring&g ...
随机推荐
- 解决ios手机中input输入框光标过长的问题
修改前css部分代码: .receiving-info .receiving-info-list input { display: inline-block; width: 70%; font-siz ...
- C# 引入Sqlite 未能加载文件或程序集“System.Data.SQLite
个人博客 地址:https://www.wenhaofan.com/article/20190501224046 问题 在Visual Studio 中 使用NuGet 通过 install-pack ...
- Oracle Solaris 10 重启后提示 Bad PBR sig
Solaris 10 安装完毕重启后提示 Bad PBR sig 在磁盘分区的时候,默认自带的 overlap 不要删除,否则启动报错. 分区时,保留overlap(默认显示总容量大小)分区.安装操作 ...
- Linux一些基本命令、inode定义、软硬链接
1.创建普通文件命令:touch 命令 2.创建目录文件命令:mkdir 命令 3.删除普通文件命令:rm 命令 4.删除目录文件命令:rmdir 命令 5.给普通文件写东西命令:vim 命令 6.查 ...
- KMP(模板)
算法讲解: KMP算法最浅显易懂 模板来源: 从头到尾彻底理解KMP 首先:KMP的模板为: void get_next(char *a, int *nex) { nex[] = ; , j = ; ...
- 图像处理——RGB-YRK-YUV-YCrCb的转换
一.和rgb之间换算公式的差异 yuv<-->rgb Y'= 0.299*R' + 0.587*G' + 0.114*B' U'= -0.147*R' - 0.289*G' + 0.436 ...
- react-路由和Ant design
路由的使用 react-router import React from 'react' // 如果要使用 路由模块,第一步,运行 yarn add react-router-dom // 第二步,导 ...
- openWRT和LuCI
openwrt是一套集成在板子上的系统,通过ip进入到其页面上 Luci是lua和UCI统一配置接口的合体,实现路由的网页配置界面(相当于一个前端框架)
- 机器学习作业(一)线性回归——Python(numpy)实现
题目太长啦!文档下载[传送门] 第1题 简述:设计一个5*5的单位矩阵. import numpy as np A = np.eye(5) print(A) 运行结果: 第2题 简述:实现单变量线性回 ...
- asp.net core 发布到linux下Docker
1.linux Docker 安装 内核升级:https://www.cnblogs.com/zksfyz/p/7919425.html 安装: https://www.runoob.com/do ...