题意
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