其实感觉这道题在D简单了(但我都没做到这一题,路径最多的方式只有一种,将所有的边都走一遍,从第一行开始,向右走到头,然后向左回来,向下一格,向右走到头,然后上下左重复直到第一列,如此重复直到最后一行,最后一步为向上到第一行第一列,注意输出的时候要判断一下0的情况

#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) ((x)&(-x))
typedef long long LL; void run_case() {
int n, m, k;
cin >> n >> m >> k;
vector<pair<int,string>> store, ans;
int cnt = ;
for(int i = ; i <= n; ++i) {
store.push_back(make_pair(m-, "R"));
cnt += store.back().first * store.back().second.size();
if(i == ) store.push_back(make_pair(m-, "L"));
else store.push_back(make_pair(m-, "UDL"));
cnt += store.back().first * store.back().second.size();
if(i == n) store.push_back(make_pair(n-, "U"));
else store.push_back(make_pair(, "D"));
cnt += store.back().first * store.back().second.size();
}
if(cnt < k) {
cout << "NO\n";
return;
}
while(cnt > k) {
string now = store.back().second;
int cur = store.back().first*now.size();
store.pop_back();
cnt -= cur;
if(cnt >= k) continue;
cur = k - cnt;
if(cur / now.size()) store.push_back(make_pair(cur/now.size(), now));
now.resize(cur%now.size());
if(now.size()) store.push_back(make_pair(, now));
cnt = k;
}
cout << "YES\n";
for(auto i : store) {
if(i.first) ans.push_back(i);
}
cout << ans.size() << "\n";
for(auto i : ans) {
cout << i.first << " " << i.second << "\n";
}
} int main() {
ios::sync_with_stdio(false), cin.tie();
//cout.setf(ios_base::showpoint);cout.precision(10);
//int t; cin >> t;
//while(t--)
run_case();
cout.flush();
return ;
}

Codeforces1301D的更多相关文章

  1. Codeforces1301D Time to Run

    (搬运一下部分官方题解) Description link 或者洛谷link 到时候就有中文翻译了,不过这个题机翻没毛病 Solution 首先这是一道模拟题-- 不要管题目中的循环移动的问题,直接按 ...

随机推荐

  1. 两个Beta函数类型的积分及其一般形式

    \[\Large\displaystyle \int_{0}^{1}\frac{\sqrt[4]{x\left ( 1-x \right )^{3}}}{\left ( 1+x \right )^{3 ...

  2. 吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:TensorFlow与神经网络的实现

    import tensorflow as tf import numpy as np ''' 初始化运算图,它包含了上节提到的各个运算单元,它将为W,x,b,h构造运算部件,并将它们连接 起来 ''' ...

  3. maven 配置环境变量后报错jdk版本不符

    不需要再cmd 输入java -version,因为环境变量里配置的不一定是cmd显示版本,直接看环境变量改成maven要求的jdk版本即可.

  4. MySQL主从复制原理的是啥?

    主库将变更写binlog日志,然后从库连接到主库之后,从库有一个IO线程,将主库的binlog日志拷贝到自己本地,写入一个中继日志中. 接着从库中有一个SQL线程会从中继日志读取binlog,然后执行 ...

  5. iOS 与 js交互的其一方法 WebViewJavascriptBridge的使用

    #import <WebViewJavascriptBridge.h> /// @interface ZWBridgeViewController ()<WKNavigationDe ...

  6. mysql_pw 指令 数据库创建过程

    ------------------pw_db数据库创建过程各表创建指令-------------------------- create database pw_db; #创建一个数据库use pw ...

  7. 杭电 2013 猴子吃桃 递归解法&循环解法

    题目估计看到过3次不止了,所以还是想复习下递归的运用. 奉上递归代码: #include <iostream> #include<math.h> #include <io ...

  8. (转)Oracle数据库备份与恢复总结

    http://blog.csdn.net/xyz846/article/details/6437963 http://blog.csdn.net/hollboy/article/details/867 ...

  9. redis哨兵模式启动redis-sentinel sentinel.conf 报错

    [root@node01 redis-3.2.8]# redis-sentinel sentinel.conf *** FATAL CONFIG FILE ERROR ***Reading the c ...

  10. 用apt-get解决dpkg过程中出现的依赖问题

    dpkg命令不解决依赖问题,这点对新手很不友好 当使用dpkg -i *.deb 安装出现依赖问题的时候,可以尝试如下解决方法: apt-get -f -y install # 复制粘贴回车,inst ...