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 ...
随机推荐
- 敌兵布阵 HDU - 1166 板子题
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> ...
- Android中的内存管理机制以及正确的使用方式
概述 从操作系统的角度来说,内存就是一块数据存储区域,属于可被操作系统调度的资源.现代多任务(进程)的操作系统中,内存管理尤为重要,操作系统需要为每一个进程合理的分配内存资源,所以可以从两方面来理解操 ...
- react-父子子孙组件嵌套-context
方案一 import React from 'react' import ReactTypes from 'prop-types' /* // 最外层的父组件 export default class ...
- 关于Django图片上传
首先要设置settings # 上传文件 MEDIA_ROOT = 'media' # 项目下的目录 MEDIA_URL = "/media/" # 跟STATIC_URL类似,指 ...
- P问题,NP问题,NPC问题学习笔记
参考:https://www.luogu.org/blog/styx-ferryman/chu-sai-bei-kao-gan-huo-p-wen-ti-np-wen-ti-npc-wen-ti-sh ...
- LED Keychain: Timeless Business Gift
Every business owner understands the importance of reducing marketing budgets and investing in sales ...
- 关于Oracle的使用
1.查看数据库 在sqlplus / as sysdba执行后,再执行select name from v$database; 2.执行1后继续查看该数据库下的表 select table_name ...
- Mariadb Galera Cluster 搭建集群
1.安装MariaDB 和Galera 见另外一篇博客 2.环境修改 2.1 防火墙和SELinux 这里不做说明,参照网上教程,和官方的配置 2.2. 创建用于节点同步的账号 [root@local ...
- 重载(Overload)和重写(Override)的区别是什么?
首先java程序的运行分为编译和运行两部分. 所以重载和重写在这一点就有很明显的区别,因为重写方法的方法名和参数个数类型都一样,所以在java虚拟机的编译阶段是识别不出重写的方法的不同,在运行期间才可 ...
- ArcMap空间参考警告窗口关了怎么重新打开
有时候加载的数据没有空间参考或者空间参考和数据框的空间参考不一致,都会弹出警告的对话框 如果选中不再向我发出警告复选框,之后又想显示它,可启动 AdvancedArcMapSettings.exe 工 ...