先把一种最长路线记录下来,根据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(模拟)的更多相关文章

  1. Codeforces Round #249 (Div. 2) (模拟)

    C. Cardiogram time limit per test 1 second memory limit per test 256 megabytes input standard input ...

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

  3. 题解——Codeforces Round #508 (Div. 2) T1 (模拟)

    依照题意暴力模拟即可A掉 #include <cstdio> #include <algorithm> #include <cstring> #include &l ...

  4. Codeforces Round #281 (Div. 2) B 模拟

    B. Vasya and Wrestling time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  5. Codeforces Round #281 (Div. 2) A 模拟

    A. Vasya and Football time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  6. Codeforces Round #362 (Div. 2) B 模拟

    B. Barnicle time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...

  7. Codeforces Round #619 (Div. 2)E思维+二维RMQ

    题:https://codeforces.com/contest/1301/problem/E 题意:给个n*m的图形,q个询问,每次询问问询问区间最大的合法logo的面积是多少 分析:由于logo是 ...

  8. Codeforces Round #357 (Div. 2) 优先队列+模拟

    C. Heap Operations time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  9. Codeforces Round #619 (Div. 2) A~D题解

    最近网课也开始了,牛客上一堆比赛题目也没补,所以就D题后面的也懒得补了 A.Three String 水题 #include <cstdio> #include <cstring&g ...

随机推荐

  1. gulp常用插件之yargs使用

    更多gulp常用插件使用请访问:gulp常用插件汇总 yargs这是一款通过解析参数并生成优雅的用户界面来帮助您构建交互式命令行工具.处理命令行参数的通用解决方案,只要一句代码 var args = ...

  2. 【巨杉数据库SequoiaDB】社区分享 | SequoiaDB + JanusGraph 实践

    本文来自社区用户投稿,感谢小伙伴的技术分享 项目背景 大家好!在春节这段时间里,由于一直在家,所以花时间捣鼓了一下代码,自己做了 SequoiaDB 和 JanusGraph 的兼容扩展工作. 自己觉 ...

  3. BZOJ2780(广义后缀自动机,set启发式合并)

    BZOJ2780(广义后缀自动机,set启发式合并) 题面 自己找去 HINT 就是给多个文本串,然后每次查询的时候问你这个串在多少个文本串中出现过.因为多个文本串,那么直接就往广义后缀自动机上思考啊 ...

  4. 题解 AT4556 【12/22】

    题目传送门. ___________ 主要思路 我们可以使用\(C++\)语言中的\(string\)字符串来解. 先定义一个字符串\(s\),并输入\(s\). string s; cin>& ...

  5. ECMAScript基本语法——⑤运算符 赋值运算符

    左边的变量等于等号左边的内容移到右边

  6. 如何处理pom文件中没有找到HUB检查到高危漏洞的依赖包

    最近使用HUB工具检查到maven工程中存在高危险漏洞,虽然定位到具体的引用包了,但是在pom文件中却没有发现该依赖包.此时,我们就需要用到这条命令mvn dependency:tree,该命令会将m ...

  7. [USACO10MAR] 伟大的奶牛聚集 - 树形dp

    每个点有重数,求到所有点距离最小的点 就是魔改的重心了 #include <bits/stdc++.h> using namespace std; #define int long lon ...

  8. 解决Office2016输入失效密钥之后无法输入的问题

    第一步: 以管理员的身份运行cmd 第二步输入以下命令: cscript "C:\Program Files (x86)\Microsoft Office\Office16\OSPP.VBS ...

  9. SpringBoot学习- 7、问题Could not autowire. No beans of 'xxxx' type found处理

    SpringBoot学习足迹 这个问题网上有好多同学都提到这个问题,代码可以运行,但是就是有红线,强迫症不能忍 自己试验下 1.增加一个final编译一下,再删掉就不会出红线了 public clas ...

  10. AE接口编程

    [转]原文链接:https://malagis.com/arcgis-engine-10-develop-handbook-2-1.html 使用 ArcGIS Engine,也就意味着使用里面的接口 ...