先把一种最长路线记录下来,根据k的大小存到ans中相应的答案再输出

  1. #define HAVE_STRUCT_TIMESPEC
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. vector<char>vv;
  5. vector<pair<int,char>>ans;
  6. int main(){
  7. ios::sync_with_stdio(false);
  8. cin.tie(NULL);
  9. cout.tie(NULL);
  10. int n,m,k;
  11. cin>>n>>m>>k;
  12. int mx=*m*n-*m-*n;
  13. if(k>mx){
  14. cout<<"NO\n";
  15. return ;
  16. }
  17. for(int i=;i<n;++i)
  18. vv.emplace_back('D');
  19. for(int i=;i<m;++i)
  20. vv.emplace_back('R');
  21. for(int j=m;j>;--j){
  22. for(int i=n;i>;--i)
  23. vv.emplace_back('U');
  24. for(int i=;i<n;++i)
  25. vv.emplace_back('D');
  26. vv.emplace_back('L');
  27. }
  28. for(int i=n-;i>=;--i){
  29. vv.emplace_back('U');
  30. for(int j=;j<m;++j)
  31. vv.emplace_back('R');
  32. for(int j=m;j>;--j)
  33. vv.emplace_back('L');
  34. }
  35. char pos=vv[];
  36. int cnt=;
  37. for(int i=;i<k;++i)
  38. if(pos==vv[i])
  39. ++cnt;
  40. else{
  41. ans.push_back({cnt,pos});
  42. pos=vv[i];
  43. cnt=;
  44. }
  45. if(cnt)
  46. ans.push_back({cnt,pos});
  47. cout<<"YES\n";
  48. cout<<ans.size()<<"\n";
  49. for(auto it:ans)
  50. cout<<it.first<<" "<<it.second<<"\n";
  51. return ;
  52. }

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. StyleLint 使用指南

    StyleLint 是『一个强大的.现代化的 CSS 检测工具』, 与 ESLint 类似, 是通过定义一系列的编码风格规则帮助我们避免在样式表中出现错误. 安装stylelint npm insta ...

  2. UVA10085-不知错在何处

    #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #i ...

  3. 关于MySQL数据库中null的那些事

    在mysql数据库中,null是一个经常出现的情况,关于mysql中的null,有哪些注意事项呢?下面简单总结归纳下,后续会不断补充. 1. is null 首先判断数据库中某一列的值是否为null, ...

  4. PIE-SDK For C++内存栅格数据的创建

    1.功能简介 目前在地理信息领域中数据包括矢量和栅格两种数据组织形式.每一种数据有不同的数据格式,目前PIE SDK支持多种数据格式的数据创建,下面对内存栅格数据格式的数据创建功能进行介绍. 2.功能 ...

  5. 线段树(lazy标记)-- 模板

    ], lazy[MAXN << ]; void PushUp(int rt) { ans[rt] = ans[rt << ] + ans[rt << | ]; } ...

  6. Python 高维数组“稀疏矩阵”scipy sparse学习笔记

    scipy 里面的sparse函数进行的矩阵存储 可以节省内存 主要是scipy包里面的 sparse 这里目前只用到两个 稀疏矩阵的读取 sparse.load() 转稀疏矩阵为普通矩阵 spars ...

  7. gulp-css-spriter 雪碧图合并

    相信做前端的同学都做过这样的事情,为优化图片,减少请求会把拿到切好的图标图片,通过ps(或者其他工具)把图片合并到一张图里面,再通过css定位把对于的样式写出来引用的html里面.gulp-css-s ...

  8. 缓存 - 数据缓存 - IndexedDB - Dexie.js

    Classes Dexie DexieError Collection and():Add JS based criteria to collection(向集合添加基于JS的条件) delete() ...

  9. java中拦截器与过滤器

    注:文摘自网络,仅供自己参考 1.首先要明确什么是拦截器.什么是过滤器 1.1 什么是拦截器: 拦截器,在AOP(Aspect-Oriented Programming)中用于在某个方法或字段被访问之 ...

  10. 简单scrapy爬虫实例

    简单scrapy爬虫实例 流程分析 抓取内容:网站课程 页面:https://edu.hellobi.com 数据:课程名.课程链接及学习人数 观察页面url变化规律以及页面源代码帮助我们获取所有数据 ...