AtCoder - 2282 (思维+构造)
2024-08-25 15:31:38
题意
https://vjudge.net/problem/AtCoder-2282
告诉你sx,sy,tx,ty,问从s走到t,再从t走到s,再从s走到t,再从t回到s的最短路,每次只能上下左右选一个走1,除了s和t,其他点只能走一次。
思路
这是个沙雕构造题,我画出来了却没看出来。。太沙雕了。
借用别人的图:
然后乱走即可。。
代码
#include <bits/stdc++.h> using namespace std;
#define ll long long
const int N=1e3+5;
const int mod=1e9+7;
int main()
{
ios::sync_with_stdio(false);
int sx,sy,tx,ty;
cin>>sx>>sy>>tx>>ty;
cout<<"D";
for(int i=0; i<tx-sx+1; i++)
cout<<"R";
for(int i=0; i<ty-sy+1; i++)
cout<<"U";
for(int i=0; i<tx-sx+1; i++)
cout<<"L";
for(int i=0; i<ty-sy; i++)
cout<<"D";
for(int i=0; i<tx-sx; i++)
cout<<"R";
for(int i=0; i<ty-sy+1; i++)
cout<<"U";
for(int i=0; i<tx-sx+1; i++)
cout<<"L";
for(int i=0; i<ty-sy+1; i++)
cout<<"D";
cout<<"R"<<endl;
return 0;
}
//1 2 4 8 16 30 60 96
最新文章
- 智力火柴游戏Android源码项目
- HTML5之API
- Linux中的find(-atime、-ctime、-mtime)指令分析
- 介绍一些chrome 好用的插件和快捷键
- curl api create domain
- android实现qq邮箱多个图标效果
- println()函数输出int类型返回值错误的问题
- 采访ServiceStack的项目领导Demis Bellot——第2部分(转)
- cassandra 之 jdbc 使用【java、scala】
- 委托、事件和Lambda
- JS实现 页面提交防刷新等待提示
- php smarty section使用
- Dhroid框架笔记(IOC、EventBus)
- 巧记--Css选择器
- MathML转换成OfficeML
- spring的list ,set,map,properties注入(set,get注入)
- 常用VI操作命令
- Linux 下的 python 虚拟环境 + vim快捷方式
- [CTSC2010]珠宝商 SAM+后缀树+点分治
- VMware Ubuntu蓝屏问题解决
热门文章
- 剑指offer 27:二叉搜索树与双向链表
- (入门SpringBoot)SpringBoot加接口操作日志好方法(九)
- 阿里云ubuntu 16.04 搭建pptpd 第二版
- Day8 - Python基础8 异常处理、反射、单例模式
- AcWing&#160;45.&#160;之字形打印二叉树
- AcWing&#160;46.&#160;二叉搜索树的后序遍历序列
- 加速自己的hexo,使用GitHub+Coding实现国内外网站加速
- React中引用CSS样式的方法
- Maven配置教程
- 使用Kafka建立可靠的高性能分布式消息传递基础结构