![信息學(xué)集訓(xùn)隊(duì)作業(yè)0064-puzzleout_第1頁(yè)](http://file4.renrendoc.com/view/801aa180d884166c6e176d633dbe1600/801aa180d884166c6e176d633dbe16001.gif)
![信息學(xué)集訓(xùn)隊(duì)作業(yè)0064-puzzleout_第2頁(yè)](http://file4.renrendoc.com/view/801aa180d884166c6e176d633dbe1600/801aa180d884166c6e176d633dbe16002.gif)
![信息學(xué)集訓(xùn)隊(duì)作業(yè)0064-puzzleout_第3頁(yè)](http://file4.renrendoc.com/view/801aa180d884166c6e176d633dbe1600/801aa180d884166c6e176d633dbe16003.gif)
![信息學(xué)集訓(xùn)隊(duì)作業(yè)0064-puzzleout_第4頁(yè)](http://file4.renrendoc.com/view/801aa180d884166c6e176d633dbe1600/801aa180d884166c6e176d633dbe16004.gif)
![信息學(xué)集訓(xùn)隊(duì)作業(yè)0064-puzzleout_第5頁(yè)](http://file4.renrendoc.com/view/801aa180d884166c6e176d633dbe1600/801aa180d884166c6e176d633dbe16005.gif)
下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、題目 0064 Puzzleout()題目來(lái)源:Tehran01者:林希德一、英文原文Puzzle OutThe scientific committee members of the 26CM/ICPC, who design the contest problems,use the following encryption algorithm to communicate the problem drafts securely through theernet. To encrypext, all occurrenof each letter is replaced winother le
2、tter (siblyitself), sucht no two letters are encrypted to the same letter. Both original and encrypted textsconsist of only upper-case letters and bls. Bls are not encrypted and are repeated exactly inthe encrypted text. As an exle, the string GSRH RH GSV URIHG HZNKOV is the encrypted formLE accordi
3、ng to the encryption table (A Z, B Y, C X, ,of THIS IS THEZ A).SA recipient of a problem drafs lost the encryption table, but he has a dictionary which includeshe problems. You are to help him set up a decryption table toall thesible words appearingenable him restore the original problem draft from
4、the encrypted one. Given a dictionary of theoriginal words usedhe text, and the encrypted text, we want to find the right encryption tablesucht after decrypting the given encrypted text back to the original one, all words can be foundhe dictionary.Input (filename: E.IN)Thepart of the input file is a
5、 dictionary of English words common to all test cases. Theline of the file is d (1 d 50000); the number of wordshe dictionary, followed by d lineseach containing a wordhe dictionary. The wordshe dictionary are sorted in alphabeticalorder and all are in uppercase. Each word has at most 20 characters,
6、 but you can amet sumof the length of all wordshe dictionary is no moren 350,000. The next line contains a singleeger t (1 t 10), the number of test cases, followed by the input data for each test case. Eachtest case, which is preceded by a single blline, consists of multiple lines in the input file
7、forming the encrypted text. Each line has a string containing only uppercase letters and bl. Youmay amet no line break is occurred in the middle of a word and there may be arbitrarynumber of blcharacters atof each line.um length of input lines is 80.Output (filename: E.OUT)The output file contains e
8、xactly t lines, each corresponding to a test case. Each line should containasinglestringof26characterswhichistheencryptionofthestringABCDEFGHIJKLMNOPQRSTUVWXYZ according to the encryption table used in the test case.Lettershe output string should be in uppercase. It issiblet some letters do not appe
9、ar inthe encrypted texdecrypted verall.his case, put a * mark in place of those letters not appearingheof the input text. If the test case has no solution, the output line should contain#No solution#. If there is moren onesible encryption table for a test case, the outputline should contain #Moren o
10、ne solution#.二、中文翻譯有一個(gè)加密方法是把每個(gè)英文字母映變換成不同的英文字母,給出 26 個(gè)字母的一個(gè)排列 C1,C2,C3,則把加密的時(shí)候應(yīng)該把字母表中第 I 個(gè)字母變換成字母 Ci,空格不變。例如對(duì)于排列 ZYXWVUTSRQPONMLKJIHGFEDCBA,文本 THIS IS THESLE將變成 GSRH RH GSV URIHG HZNKOV。該加密方法十分不保險(xiǎn),因?yàn)樵诘玫搅嗣芪囊院?,即使沒有對(duì)應(yīng)關(guān)系表,也能根據(jù)英語(yǔ)中可能有的詞匯猜出原文。編程完成這項(xiàng)工作。【輸入】文件 dict.txt 第一行為一個(gè)整數(shù) D(1=d=50000),為可能出現(xiàn)的單詞數(shù)目。以下 D行每行
11、一個(gè)單詞,每個(gè)單詞最多 20 個(gè)字符,所有單詞長(zhǎng)度和不大于 350,000。文件 puzzle.in 第一行為密文的單詞數(shù)目T,以下 T 行,每行一個(gè)單詞?!据敵觥咳绻麑?duì)應(yīng)表不唯一(忽略原文沒有出現(xiàn)的字母)或者無(wú)解,輸出-1,否則為一個(gè)長(zhǎng)度為 26 的字符串,即對(duì)應(yīng)表。原文中沒有出現(xiàn)的字母處打“*”。【樣例】 dict.txt 14BECHANGEIN IS MUSTSLE SEE THE THIS TO WISH WORLD YOU4以下數(shù)據(jù)都采用上面的 dict.txt puzzle.in5GSRH RHGSVURIHGHZNKOVPuzzle.outZ*VU*SR*ON*K*IHG*Pu
12、zzle.in 12IZM BMVU SP UGPRGTANP IZM KFVG UZVPP FA UGPKZWCQPuzzle.outTSRQP*NGF*CBAZ*WVUM*K*I*Puzzle.in 2XYZABCDEFGPuzzle.out-1puzzle.in 2XZYABDPuzzle.out-1三、初步情況搜索搜索只知道搜我也認(rèn)為是搜索。這道題目目前我只能嘗試用搜索,但是速度不理想根據(jù)數(shù)據(jù)靠英語(yǔ)單詞來(lái)猜測(cè)?只能搜索,先搜長(zhǎng)單詞應(yīng)該更有效。璟我覺得是搜索。剪枝可以借鑒程復(fù)雜度就會(huì)很高。字符的某些。但是優(yōu)化的措施一多,應(yīng)用起來(lái)編因?yàn)轭}目所給的數(shù)據(jù)都很?。疵總€(gè) Puzzle.in)而且
13、本文中也出現(xiàn)了如果出現(xiàn)多解打出-1,所以應(yīng)該只有用搜索來(lái)解決。每次選擇對(duì)應(yīng)情況數(shù)最少的單詞來(lái)搜吧!效率應(yīng)該還可以。昆我覺得每次搜索可能對(duì)應(yīng)的單詞數(shù)最少的密文,這樣速度可能比較快似乎只能通過統(tǒng)計(jì)字母出現(xiàn)的頻率來(lái)使搜索簡(jiǎn)化,當(dāng)然還需要對(duì)不同長(zhǎng)度單詞的統(tǒng)計(jì)。但我依然覺得為了要判斷唯一性,似乎還是需要全部搜索可以先判斷出每個(gè)密文中的單詞對(duì)應(yīng)單詞表中的單詞的所有可能情況,按照可能情況數(shù)遞增的順序逐一考慮密文中的每個(gè)單詞。搜索。不過既然給了一個(gè)單詞表,可以統(tǒng)計(jì)其中字母出現(xiàn)頻率,按這個(gè)頻率搜索對(duì)應(yīng)字母應(yīng)該很容易找到一組解。如果找不到,無(wú)解就很容易判斷了;如果找到了,繼續(xù)找找,就知道是確定解還是許多解的情況了。感覺就是一種搜索。找出最短的一個(gè)密文單詞,枚舉所有的可能單詞。然后,用枚舉出來(lái)的對(duì)應(yīng)關(guān)系,將其它單詞的一些字母試著,然后再繼續(xù)枚舉未字母最少的密文單詞。如此遞歸,直至找到一個(gè)能夠所有密文的方法。這道題可以動(dòng)手編一下,的算法如下:開始的時(shí)候,就每個(gè)單詞掃描數(shù)據(jù)文件一遍,從單詞長(zhǎng)度和單詞內(nèi)字母的重復(fù)情況方面進(jìn)行篩選,做成 T 個(gè)集合。然后從這 T 個(gè)集合中選取F=該集合的基數(shù)*(M+1-該單詞中出現(xiàn)的字母數(shù)量)*(S+1-該單詞的字母在其他未選擇單詞中出現(xiàn)的次數(shù))的積最小的
溫馨提示
- 1. 本站所有資源如無(wú)特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 26《好的故事》說課稿-2024-2025學(xué)年語(yǔ)文六年級(jí)上冊(cè)統(tǒng)編版
- 1場(chǎng)景歌說課稿-2024-2025學(xué)年統(tǒng)編版語(yǔ)文二年級(jí)上冊(cè)
- 2024年秋一年級(jí)道德與法治下冊(cè) 第二單元 我和大自然 5 風(fēng)兒輕輕吹說課稿 新人教版
- 18古詩(shī)三首浪淘沙(其一)說課稿-2024-2025學(xué)年六年級(jí)上冊(cè)語(yǔ)文統(tǒng)編版
- 8 設(shè)計(jì)制作小車(二) 說課稿-2024-2025學(xué)年科學(xué)四年級(jí)上冊(cè)教科版
- 23《月光曲》說課稿-2024-2025學(xué)年語(yǔ)文六年級(jí)上冊(cè)統(tǒng)編版
- 1 24時(shí)計(jì)時(shí)法(說課稿)-2024-2025學(xué)年三年級(jí)上冊(cè)數(shù)學(xué)人教版001
- 2023九年級(jí)道德與法治上冊(cè) 第三單元 文明與家園 第五課 守望精神家園第2框 凝聚價(jià)值追求說課稿 新人教版
- 2025北京市飼料采購(gòu)合同新
- 2025建造船舶所要用到的合同
- 農(nóng)產(chǎn)品貯運(yùn)與加工考試題(附答案)
- 學(xué)校財(cái)務(wù)年終工作總結(jié)4
- 2025年人民教育出版社有限公司招聘筆試參考題庫(kù)含答案解析
- 康復(fù)醫(yī)學(xué)治療技術(shù)(士)復(fù)習(xí)題及答案
- 《血管性血友病》課件
- 2025年汽車加氣站作業(yè)人員安全全國(guó)考試題庫(kù)(含答案)
- 2024年司法考試完整真題及答案
- 高三日語(yǔ)一輪復(fù)習(xí)日語(yǔ)助詞「に」和「を」的全部用法課件
- 2024年山東省高考政治試卷真題(含答案逐題解析)
- 2024年執(zhí)業(yè)藥師繼續(xù)教育專業(yè)答案
- 2024-2025學(xué)年人教版七年級(jí)數(shù)學(xué)上冊(cè)期末達(dá)標(biāo)測(cè)試卷(含答案)
評(píng)論
0/150
提交評(píng)論