


下載本文檔
版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
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 剛剛學會如何拼圖。她現(xiàn)在開始玩 15 塊的小拼圖了。同時,他也在玩同樣的拼圖。為了是變得一些,他把
9、所有的拼圖塊翻轉(zhuǎn)過來使得他不能看到拼塊上的圖畫?,F(xiàn)在他在尋找這樣的拼圖的解答。一般來說,解答應該是存在的,但是他不敢肯定 Barborka 沒有換掉一部分拼塊。寫一個程序讀入一系列的拼塊并且?guī)退袛嗍欠窨梢园堰@些拼塊拼入一個給出長寬的矩形中。輸入格式:輸入包含很多塊,除了最后一塊之外,每塊都描述了一個拼圖問題。每塊的第一行包含由空格分隔的正整數(shù)n 和m,0 n, m = 6。n 和m 分別表示拼圖的行數(shù)和列數(shù)。這一塊的下面n * m 行是拼快的描述。每個拼塊是 3cm 寬 4cm 高的四邊中間可能有突起或凹陷的矩形塊。一個拼塊每一條邊都是下列情況之一:1. 平的-這樣的邊只能在最終圖形的邊上2
10、. 中間有突起3. 中間有凹陷像通常的拼圖一樣,兩條邊能拼在一起當且僅當其中一個有突起而另一個有凹陷。用F 表示平邊,O 表示突邊且I 表示凹邊。每個拼塊的四邊按上、右、下、左的順序依次給出。為了簡化問題,拼塊不能被旋轉(zhuǎn)。每塊結(jié)束后有一空行,最后一塊是兩個由空格隔開的 0。輸出格式:對每塊輸出一行。輸出 YES 如果輸入的拼圖問題有解,否則輸出 NO。最后一塊沒有對應的輸出。樣例輸入:3 5FOOF FOOI FOOI FOOI FFOI IOOF IOOI IOOI IOOI IFOI IOFF IOFI IOFI IOFI IFFI 0 0樣例輸出:YES理由:此題雖然數(shù)據(jù)規(guī)模很小,搜索完全可以解決。但拼塊總共不會超過 81 種且不能旋 轉(zhuǎn),問題的數(shù)學模型并不復雜,而且四個角上的拼塊顯然是可以直接“構(gòu)造”出來的,所以我感覺可能有多項式級的算法直接判定解是否存在。在 zju 上有很多人的程序在 0.03 秒內(nèi)通過,這一點也多少為想法提供了:),所以,即使不能找到多項式級的算法,至少也能找到很強的
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 大學生職業(yè)生涯規(guī)劃與個人能力展示
- 2024秋八年級道德與法治上冊 第四單元 維護國家利益 第九課 樹立總體國家安全觀 第1框 認識總體國家安全觀教學設計 新人教版
- 三年級信息技術上冊 第六課 巧玩電腦小游戲教學設計 華中師大版
- Unit 3 Weather(教學設計)-2023-2024學年人教PEP版英語四年級下冊
- 2024-2025學年高中生物 第三章 酶的應用技術實踐 第二節(jié) 制備和應用固定化酶教學設計 蘇教版選修1
- 《除數(shù)是一位數(shù)的除法 - 筆算除法》(教學設計)-2023-2024學年三年級下冊數(shù)學人教版
- 三年級下冊道德與法治教學設計-6《規(guī)則守護我們成長》第二課時 守規(guī)才有序 蘇教版
- 2023九年級數(shù)學上冊 第四章 圖形的相似8 圖形的位似第1課時 位似圖形及其畫法教學設計 (新版)北師大版
- 血漿站后廚工作總結(jié)
- 2023二年級數(shù)學下冊 8 克和千克第1課時 克和千克的認識教學設計 新人教版
- 基于大概念的高中歷史大單元教學
- (2024年)保安培訓圖文課件
- 《養(yǎng)老護理員》-課件:協(xié)助臥床老年人使用便器排便
- 統(tǒng)編版語文八年級下冊全冊大單元整體教學設計表格式教案
- 特種加工技術課件
- 提升教師數(shù)字素養(yǎng)培訓方案
- 康恩貝流程優(yōu)化與ERP實施項目方案建議書20150612V1.0
- 坑機安全操作規(guī)程范本
- 飼料廠獎懲制度匯編
- HFSS射頻仿真設計實例大全
- 《互聯(lián)網(wǎng)營銷課件:市場拓展的七大技巧》
評論
0/150
提交評論