中关村手机网站建设,wordpress 无法翻页,做网站接雕塑业务,erp系统一般多少钱一年传送门 文章目录题意#xff1a;思路#xff1a;题意#xff1a;
给你一个n∗mn*mn∗m的矩阵#xff0c;每两个相邻点之间有个双向边#xff0c;问你能不能走满kkk步#xff0c;每一步走的边不同#xff0c;但是点可以相同#xff0c;换句话说就是走的边不能再走了。输…传送门
文章目录题意思路题意
给你一个n∗mn*mn∗m的矩阵每两个相邻点之间有个双向边问你能不能走满kkk步每一步走的边不同但是点可以相同换句话说就是走的边不能再走了。输出的时候输出一个fff和一串不超过444个的字符表示按照这个字符走fff次。输出的行数不能超过300030003000行。
思路
能看出来这是个欧拉回路每个点度数为偶数一定有解所以先判断一下是否≤(4∗n∗m−2∗n−2∗m)\le (4*n*m-2*n-2*m)≤(4∗n∗m−2∗n−2∗m)。 判断有解后我们考虑如何构造解。 一开始我想的是先走完一行和一列让后将问题转换成(n−1)∗(n−1)(n-1)*(n-1)(n−1)∗(n−1)的子问题但是这显然是不行的因为从111出发想要每个边走一遍那么终点一定在111号点所以考虑其他构造方法。 由于我们有300030003000的限制所以我们不能随便构造下面介绍一个非常简单就能实现的构造方法 (1)(1)(1)先走m−1m-1m−1步到最右边。 (2)(2)(2)向下走n−1n-1n−1步到最下边。 (3)(3)(3)向上走n−1n-1n−1步回到刚才的点。 (4)(4)(4)向左走一步。 (5)(5)(5)重复(2),(3),(4)(2),(3),(4)(2),(3),(4)一直回到起点111。 (6)(6)(6)向下走一步。 (7)(7)(7)向右走m−1m-1m−1步。 (8)(8)(8)向左走m−1m-1m−1步。 (9)(9)(9)重复(6),(7),(8)(6),(7),(8)(6),(7),(8)一直到最下面的点。 (10)(10)(10)向上走n−1n-1n−1步。 这个方案的总次数上限是6∗n6*n6∗n当然达不到上限正好是300030003000所以可行。 当然我们还有更好的构造方法。 考虑题目说的字符串不超过444个所以利用这个性质考虑优化。 可以发现我们上面(2),(3)(2),(3)(2),(3)步是一直走到底我们考虑只往下走一个位置再向上走一个位置再向左走一个位置这个操作字符是DULDULDUL我们执行n−1n-1n−1次即可。每一行都可以这样做。但是最后一行只能先RRR再LLL因为他下面没有行了。 第二种的实现细节很多就懒得写了。
// Problem: D. Time to Run
// Contest: Codeforces - Codeforces Round #619 (Div. 2)
// URL: https://codeforces.com/contest/1301/problem/D
// Memory Limit: 256 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)//#pragma GCC optimize(Ofast,no-stack-protector,unroll-loops,fast-math)
//#pragma GCC target(sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tunenative)
//#pragma GCC optimize(2)
#includecstdio
#includeiostream
#includestring
#includecstring
#includemap
#includecmath
#includecctype
#includevector
#includeset
#includequeue
#includealgorithm
#includesstream
#includectime
#includecstdlib
#define X first
#define Y second
#define L (u1)
#define R (u1|1)
#define pb push_back
#define mk make_pair
#define Mid (tr[u].ltr[u].r1)
#define Len(u) (tr[u].r-tr[u].l1)
#define random(a,b) ((a)rand()%((b)-(a)1))
#define db puts(---)
using namespace std;//void rd_cre() { freopen(d://dp//data.txt,w,stdout); srand(time(NULL)); }
//void rd_ac() { freopen(d://dp//data.txt,r,stdin); freopen(d://dp//AC.txt,w,stdout); }
//void rd_wa() { freopen(d://dp//data.txt,r,stdin); freopen(d://dp//WA.txt,w,stdout); }typedef long long LL;
typedef unsigned long long ULL;
typedef pairint,char PII;const int N1000010,mod1e97,INF0x3f3f3f3f;
const double eps1e-6;int n,m,k;
vectorPIIans;void run(int cnt,char ch)
{if(!k||!cnt) return;if(cntk){ans.pb({k,ch});k0;return;}k-cnt;ans.pb({cnt,ch});
}int main()
{
// ios::sync_with_stdio(false);
// cin.tie(0);scanf(%d%d%d,n,m,k);if(4*n*m-2*n-2*mk) { puts(NO); return 0; }puts(YES);run(m-1,R);for(int i1;im;i) run(n-1,D),run(n-1,U),run(1,L);for(int i1;in;i) run(1,D),run(m-1,R),run(m-1,L);run(n-1,U);printf(%d\n,ans.size());for(auto x:ans) printf(%d %c\n,x.X,x.Y);return 0;
}
/**/