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 ...
随机推荐
- 安装Ansible到CentOS(YUM)
运行环境 系统版本:CentOS Linux release 7.3.1611 (Core) 软件版本:ansible 硬件要求:无 安装过程 1.安装YUM-EPEL源 HTTP-Tools软件包由 ...
- IDEA 和 Webstorm JAR包方式破解
IDEA 和 Webstorm JAR包方式破解 IDEA 我是用的IDEA版本是 18.3,更新版本的IDEA很多激活码都不能用了,或者不好激活了. 首先下载相应的 软件版本 和破解 jar包. 下 ...
- HashMap的一些学习
1.equals和==的对比==用于比较引用和比较基本数据类型时具有不同的功能:A:比较基本数据类型,如果两个值相同,则结果为true而在比较引用时,如果引用指向内存中的同一对象,结果为true; e ...
- 133.在django中使用memcached
1. 在django中使用memcached,可以在settings.py文件中DATABASES变量下面配置CACHES缓存相关配置信息,只允许本机连接memcached就可以设置LOCATION为 ...
- 在linux中安装nginx
linux系统安装在vmware中,首先在主机中利用shell工具与虚拟机连接 1.在linux中查看虚拟机的ip地址 在终端输入 ifconfig 红框里面就是ip地址 2.在主机中打开shell工 ...
- open_basedir的配置
.user.ini的使用 1.限制目录访问 解锁: chattr -i .user.ini 加锁: chattr +i .user.ini .user.ini配置 open_basedir=/项目路径 ...
- 关闭visual studio code 智能提示功能
对于程序初学者来说,应该少用IDE的提示功能,因为这样有助于记住一些常用的函数等功能.这也是为什么戏称喜欢用notepad++(windows)或者vim编辑器(Linux)来开发代码是大神的原因,而 ...
- 杭电oj_2047——阿牛的EOF牛肉串(java实现)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2047 思路:先是列出了四个,但是没发现规律,然后开始画递归树,在其中找到了规律,算出递归式为f(n) ...
- nginx配置之后接口状态200,但是无返回数据问题小记
nginx配置可能有问题.导致nginx不能解析PHP文件,检测nginx里对于php的配置信息. location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; f ...
- Linux环境下C语言线程创建---简单代码
在Linux环境下用C语言编写线程创建. //file name: pthreadtext.c #include <stdio.h> #include <pthread.h> ...