压行带师船新大作
题目链接 27行就问你牛不牛逼
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d", &x)
#define rep(i,s,e) for(int i=s; i<e; ++i)
using namespace std;
int qaq[5005]; string s="RDU",ans[5005];
int main(){
int n,m,k,cnt(0); sc(n); sc(m); sc(k);
int num=4*n*m-2*n-2*m; if(k>num) return puts("NO"),0;
puts("YES"); if(m==1){
pf("%d\n",k>n-1?2:1); pf("%d %c\n",min(k,n-1),'D');
k-=min(k,n-1); if(k) pf("%d %c\n",k,'U'); return 0;
} rep(i,1,2*n+1){
if(!k) break; if(i&1){
if(i==2*n-1) qaq[cnt]=min(k,m-1),ans[cnt++]="R",k-=min(k,m-1);
else if(k/3>=m-1) qaq[cnt]=m-1,ans[cnt++]=s,k-=3*m-3; else{
if(k/3) qaq[cnt]=k/3,ans[cnt++]=s; if(k%3){
qaq[cnt]=1; rep(j,0,k%3) ans[cnt][j]=s[j]; cnt++;
} k=0;
}
} else{
int t=min(k,m-1); qaq[cnt]=t,ans[cnt++]="L",k-=t;
if(t==m-1&&k&&i!=2*n) qaq[cnt]=1,ans[cnt++]="D",k--;
}
} if(k) qaq[cnt]=k,ans[cnt++]="U";
pf("%d\n",cnt); rep(i,0,cnt) pf("%d %s\n",qaq[i],ans[i].c_str());
}
要讲清楚需要配图8 我懒 我就纪念一下我短的ep的代码就好了