


下載本文檔
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
_onlinejudge&Itemid=8&category=839&page=show_problem&problem=747
1/3
SpatialStructures
Computergraphics,imageprocessing,andGIS(geographicinformationsystems)allmakeuseofadatastructurecalledaquadtree.Quadtreesrepresentregionalorblockdataefficientlyandsupportefficientalgorithmsforoperationsliketheunionandintersectionofimages.
Aquadtreeforablackandwhiteimageisconstructedbysuccessivelydividingtheimageintofourequalquadrants.Ifallthepixelsinaquadrantarethesamecolor(allblackorallwhite)thedivisionprocessforthatquadrantstops.Quadrantsthatcontainbothblackandwhitepixelsaresubdividedintofourequalquadrantsandthisprocesscontinuesuntileachsubquadrantconsistsofeitherallblackorallwhitepixels.Itisentirelypossiblethatsomesubquadrantsconsistofasinglepixel.
Forexample,using0forwhiteand1forblack,theregionontheleftbelowisrepresentedbythematrixofzerosandonesinthemiddle.Thematrixisdividedintosubquadrantsasshownontherightwheregraysquaresrepresentsubquadrantsthatconsistentirelyofblackpixels.
Aquadtreeisconstructedfromtheblockstructureofanimage.Therootofthetreerepresentstheentirearrayofpixels.Eachnon-leafnodeofaquadtreehasfourchildren,correspondingtothefoursubquadrantsoftheregionrepresentedbythenode.Leafnodesrepresentregionsthatconsistofpixelsofthesamecolorandthusarenotsubdivided.Forexample,theimageshownabove,withtheblockstructureontheright,isrepresentedbythequadtreebelow.
Leafnodesarewhiteiftheycorrespondtoablockofallwhitepixels,andblackiftheycorrespondtoablockofallblackpixels.Inthetree,eachleafnodeisnumberedcorrespondingtotheblockitrepresentsinthediagramabove.Thebranchesofanon-leafnodeareorderedfromleft-to-rightasshownforthenorthwest,northeast,southwest,andsoutheastquadrants(orupper-left,upper-right,lower-left,lower-right).
Atreecanberepresentedbyasequenceofnumbersrepresentingtheroot-to-leafpathsofblacknodes.Eachpathisabasefivenumberconstructedbylabelingbrancheswith1,2,3,or4withNW=1,NE=2,SW=3,SE=4,andwiththeleastsignificantdigitofthebasefivenumbercorrespondingtothebranchfromtheroot.Forexample,thenodelabeled4has
pathNE,SWwhichis325(base5)or1710(base10);thenodelabeled12haspathSW,SEor435=2310;andthenodelabeled15haspathSE,SW,NWor1345=4410.Theentiretreeisrepresentedbythesequenceofnumbers(inbase10)
9141722234463698894113
Writeaprogramthatconvertsimagesintoroot-to-leafpathsandconvertsroot-to-leafpathsintoimages.
Input
Theinputcontainsoneormoreimages.Eachimageissquare,andthedataforanimagestartswithanintegern,where|n|isthelengthofasideofthesquare(alwaysapoweroftwo,with|n|≤64)followedbyarepresentationoftheimage.Arepresentationiseitherasequenceofn2zerosandonescomprisedof|n|linesof|n|digitsperline,orthesequenceofnumbersthatrepresenttheroot-to-leafpathsofeachblacknodeinthequadtreethatrepresentstheimage.
Ifnispositive,thezero/onerepresentationfollows;ifnisnegative,thesequenceofblacknodepathnumbers(inbase10)follows.Thesequenceisterminatedbythenumber-1.Aone-nodetreethatrepresentsl-blackimageisrepresentedbythenumber0.Aone-nodetreethatrepresentsl-whiteimageisrepresentedbyanemptysequence(nonumbers).
ofdataissignaledbyavalueof0forn.
Output
Foreachimageintheinput,firstoutputthenumberoftheimage,asshowninthesampleoutput.Thenoutputthealternateformoftheimage.
Iftheimageisrepresentedbyzerosandones,theoutputconsistsofroot-to-leafpathsofallblacknodesinthequadtreethatrepresentstheimage.Thevaluesshouldbebase10representationsofthebase5pathnumbers,andthevaluesshouldbeprintedinsortedorder.Iftherearemorethan12blacknodes,printanewlineafterevery12nodes.Thetotalnumberofblacknodesshouldbeprintedafterthepathnumbers.
Iftheimageisrepresentedbytheroot-to-leafpathsofblacknodes,theoutputconsistsofanASCIIrepresentationoftheimagewiththecharacter`.'usedforwhite/zeroandthecharacter`*'usedforblack/one.Thereshouldbencharactersperlineforann×nimage.
Printablanklineb
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 模具設計師資格考試中的時事熱點試題及答案
- 風電場項目投資可行性研究報告(范文)
- 農作物繁育員頭腦風暴及實例試題及答案
- 辦公樓內部裝修工程可行性研究報告(參考范文)
- 2024年裁判員考試知識要點試題及答案
- 2024年種子繁育從業(yè)者考試試題及答案
- 農作物種子繁育員前景分析試題及答案
- 2024年農業(yè)植保員考試的系統(tǒng)性研究試題與答案
- 模具設計師資格認證考試教學用試題及答案
- 農業(yè)植保員資格考試的課程發(fā)展與新職業(yè)標準探討試題及答案
- 2025-2030中國藜麥行業(yè)市場發(fā)展趨勢與前景展望戰(zhàn)略研究報告
- 第2單元 社會服務(整單元教學設計)-2023-2024學年四年級下冊綜合實踐活動蘇教版
- 學校校服定制合同協(xié)議
- 漢中漢源電力招聘試題及答案
- 《半導體集成電路》課件-半導體集成電路的制造工藝
- 石料場開采施工方案
- 探月精神隊課件
- 2025-2030中國設施農業(yè)行業(yè)市場發(fā)展分析及競爭格局與投資前景研究報告
- 昌樂縣南寨水庫防御洪水方案
- 第九章 人的食物來自環(huán)境【單元測試卷】(原卷版)
- 人教版(PEP)2024-2025六年級下冊英語期中測試卷(含答案含聽力原文無聽力音頻)
評論
0/150
提交評論