Codeforces1301D
其实感觉这道题在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的更多相关文章
- Codeforces1301D Time to Run
(搬运一下部分官方题解) Description link 或者洛谷link 到时候就有中文翻译了,不过这个题机翻没毛病 Solution 首先这是一道模拟题-- 不要管题目中的循环移动的问题,直接按 ...
随机推荐
- vue的页面怎么显示到android的webview中
链接:https://www.jianshu.com/p/0dd98476bba0
- java篇 之 静态
Final:不可改变 Static:静态修饰符,在编译阶段就能确定了,可以修饰成员变量,相应的称之为静态变量 是一个共享的变量(被这个类和这个类所产生的对象所共享的,他是唯一的,出生时间 为类第一次产 ...
- Go语言内置包之strconv
文章引用自 Go语言内置包之strconv Go语言中strconv包实现了基本数据类型和其字符串表示的相互转换. strconv包 strconv包实现了基本数据类型与其字符串表示的转换,主要有以下 ...
- 初始Linux软硬链接
转载 https://blog.csdn.net/libaineu2004/article/details/85918682 用实践让你明白"软链接"和"硬链接" ...
- dfs(迷宫)
问题 J: 棋盘行走 时间限制: 1 Sec 内存限制: 128 MB[命题人:admin] 题目描述 小Biu在玩一个棋盘游戏,这个游戏给出一个n*m的棋盘,并且每个点上有一个棋子,棋子的颜色 用 ...
- SpringCloud全家桶学习之概览(一)
一.概览 根据百度百科的描述,微服务架构是一项在云中部署应用和服务的新技术.而SpringCloud是微服务架构思想的一个具体实现,它为开发人员提供了构建分布式系统中一些常见模式的工具(服务注册与发现 ...
- stl_list复习
#include <iostream>#include <list>#include <algorithm>using namespace std; //底层结构是 ...
- 中山纪中Day1--普及
早上一起,扑面是瓢泼的大雨.跨过千山万水,来到纪中门前,毅然以一种大无畏的英雄气概跨进了考场. 面对四道神题.然后,我成功过五关斩六将,A掉了2道题!!! 收获:优先队列(大.小根堆) T1:APPL ...
- 例题3_1 TeX中的引号(TeX Quotes,UVa 272)
在TeX中,左双引号是“``”,右双引号是“''”.输入一篇包含双引号的文章,你的任务是把它转换成TeX的格式. 样例输入: "To be or not to be,"quoth ...
- git warning: CRLF will be replaced by LF in resources/views/sessions/create.blade.php
git config core.autocrlf false