下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、题目来源:http已有算法:搜索者:候启明题目描述:/show_problem.?=1264PuzzleTime limit: 30 SecondsMemory limit: 32768KLittarborka has juststarted to learn how to solve a picture puzzle. She hasstarted wismall onecontaining 15 pie. Her daddy tries to solve the puzzletoo. To make it upside down so solution of thea littirder
2、for himself, he has turned all puzzlet he cannot sectures on the. Now he is looking for apuzzle. Normally the solution should exist but he is not surewhether Barborka has not replaced someof the puzzy pieof anothersimilar puzzle. Help him and write aprogram which reads a description of a set ofpuzzl
3、eand decides whether itissible to assembly th not.eo arectangle with given side lengths orInputThe inponsists of blocksof lines. Each block except the lastdescribes onen and m, 0 n, mpuzzle problem.= 6 separated byheone space.line of the block there areegersTheegers n, m indicate the number of rows
4、andcolumnshe puzzle respectively.The description of individual puzzleishe following n * m lines of theblock. Each piece is a rectangle 3 centimeterswide and 4 sides. For true (secentimeters high with each side of a puzzl cture):sible juts or cavitieshe middle of itsece just one of the followingsibil
5、ities is1.there is no jut oron the side, i.e., the side is flat - such the final picture when assembling the puzzle,sidescan be used only on edges of2. thereis onejuthemiddle of the side,3. thereis onehe middle of the side.As is other sidesusual, two has apiecanbe placed side by side only if one has
6、 a jut and theon corresponding sides. We will denote the flat sides by F,the by taskwith juts by O and the sides with cavities by I. Each piece is describedfour letters characterizing its top, right, bottom, and left side. To make theeasier thecan be used only as they are described i.e. they cannot
7、be turned.After each containingblock there is an empty line. The last block consists of just one line 0 0, i.e. two zeros separated by one space.OutputThe outpontains the lines corresponding to the blockshe input. A linecontains YES if the corresponding blockhe input describes a puzzlet can becorrec
8、tly assembled. Otherwise it contains NO. There is no line corresponding to the last null block of the input.he outputSleInput3 5FOOF FOOI FOOI FOOI FFOI IOOF IOOI IOOI IOOI IFOI IOFF IOFI IOFI IOFI IFFI 0 0SleOutputYES拼图时间限制:30 秒空间限制:32768K小 Barborka 刚刚学会如何拼图。她现在开始玩 15 块的小拼图了。同时,他也在玩同样的拼图。为了是变得一些,他把
9、所有的拼图块翻转过来使得他不能看到拼块上的图画。现在他在寻找这样的拼图的解答。一般来说,解答应该是存在的,但是他不敢肯定 Barborka 没有换掉一部分拼块。写一个程序读入一系列的拼块并且帮他判断是否可以把这些拼块拼入一个给出长宽的矩形中。输入格式:输入包含很多块,除了最后一块之外,每块都描述了一个拼图问题。每块的第一行包含由空格分隔的正整数n 和m,0 n, m = 6。n 和m 分别表示拼图的行数和列数。这一块的下面n * m 行是拼快的描述。每个拼块是 3cm 宽 4cm 高的四边中间可能有突起或凹陷的矩形块。一个拼块每一条边都是下列情况之一:1. 平的-这样的边只能在最终图形的边上2
10、. 中间有突起3. 中间有凹陷像通常的拼图一样,两条边能拼在一起当且仅当其中一个有突起而另一个有凹陷。用F 表示平边,O 表示突边且I 表示凹边。每个拼块的四边按上、右、下、左的顺序依次给出。为了简化问题,拼块不能被旋转。每块结束后有一空行,最后一块是两个由空格隔开的 0。输出格式:对每块输出一行。输出 YES 如果输入的拼图问题有解,否则输出 NO。最后一块没有对应的输出。样例输入:3 5FOOF FOOI FOOI FOOI FFOI IOOF IOOI IOOI IOOI IFOI IOFF IOFI IOFI IOFI IFFI 0 0样例输出:YES理由:此题虽然数据规模很小,搜索完全可以解决。但拼块总共不会超过 81 种且不能旋 转,问题的数学模型并不复杂,而且四个角上的拼块显然是可以直接“构造”出来的,所以我感觉可能有多项式级的算法直接判定解是否存在。在 zju 上有很多人的程序在 0.03 秒内通过,这一点也多少为想法提供了:),所以,即使不能找到多项式级的算法,至少也能找到很强的
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 物流行业运力调配制度
- 文娱产业内容审核制度
- 医疗行业从业人员行为规范制度
- 制造业数字化转型保障制度
- 公司简介企业文化融资规划
- 替尔泊肽注射液产品地产项目可行性研究报告模板拿地申报
- 全国性1+X证书制度标准体系构建研究试卷
- 响水《化工安全员》实操冲刺押题卷
- 护理分级中的护理质量监控
- 麻疹防控培训专项考试试卷
- 护理人文关怀的儿科护理
- 2026年及未来5年市场数据中国精密清洗设备行业发展监测及投资战略咨询报告
- 呼和浩特市新城区(2026年)社区网格员招录考试真题库及完整答案
- 加强新兴领域知识产权保护 加快新质生产力发展2026年世界知识产权日专题讲座
- 2026年4月河北保定市九年级中考一模语文试卷
- 中国地质调查局发展研究中心2025年公开(第三批)招聘工作人员5人笔试历年典型考题及考点剖析附带答案详解
- 糖尿病坏疽课件
- 生涯教育与化学学科素养融合
- (2026年)甲状腺功能减退症基层诊疗指南
- 幼儿园教师晨午检培训
- (陕西二模)2026年陕西省高三高考适应性检测(二)英语试卷(含答案详解)+听力音频
评论
0/150
提交评论