当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

1561:Another Puzzling Problem

题目描述
You are to write a program to solve jigsaw puzzles. The input will contain the dimension of the puzzle, the dimension of the pieces, and the actual pieces of the puzzle. The pieces will be made up of ASCII characters. You are to create an output which consists of the solved puzzle.
输入解释
The first line of the input will contain three integers. These are the dimension of the puzzle (puzzles are always square), and the height and width of the pieces, respectively. The dimension of the puzzle can range from 2 to 10, and the height and width of each puzzle piece can range from 1 to 25. For example, the input "2 2 3" (without the quotes, of course) specifies a puzzle that is 2 * 2 pieces in size, with individual pieces that are 2 * 3 characters in size. All pieces have the same height and width.

The rest of the specifies the puzzle pieces in arbitrary order. Each piece is specified by an image of the piece followed by a line containing four integers ranging from -5 to +5. These values indicate the shape of the top, left, bottom and right edges of the puzzle piece, respectively. Values of 0 identify straight (i.e. outer) edges. Positive and negative edges of the same value are pairs that interlock (e.g. -5 interlocks with +5, -4 with +4, etc.). Puzzle pieces may not be rotated, and all pieces will be unique (that is, no two pieces will have the same values for all four edges). A blank line separates each puzzle piece.

Note that spaces (ASCII character 32) are valid characters in a puzzle piece. If they appear at the end of a line (or are the only characters on a line), then they will appear in the input file. All pieces will be a rectangular block of characters (ASCII codes 32 to 127), even if spaces at the end of a line make it appear differently. In short, spaces should be treated no differently than any other character.
输出解释
The output should simply contain the solved puzzle in the proper arrangement. The input puzzle will have one and only one solution.
输入样例
2 8 14
88,           
8888.         
:8888b        
  8888        
-.:888b       
' d8888       
 ,88888       
':88888       
0 3 -1 0

         o8%88
       o88%888
      8'-    -
     8'       
    d8.-=. ,==
    >8 `~` :`~
    88        
    88b. `-~  
0 0 -5 -3

.:88888       
:::8888       
:' 8888b      
    8888b     
    ,%888b.   
    %%%8--'-. 
   _%-' ---  -
.-'   =  --.  
1 4 0 0

    888b ~==~ 
    88888o--:'
    `88888| ::
    8888^^'   
   d888       
  d88%        
 /88:.__ ,    
     '''::===.
5 0 0 -4
输出样例
         o8%8888,           
       o88%8888888.         
      8'-    -:8888b        
     8'         8888        
    d8.-=. ,==-.:888b       
    >8 `~` :`~' d8888       
    88         ,88888       
    88b. `-~  ':88888       
    888b ~==~ .:88888       
    88888o--:':::8888       
    `88888| :::' 8888b      
    8888^^'       8888b     
   d888           ,%888b.   
  d88%            %%%8--'-. 
 /88:.__ ,       _%-' ---  -
     '''::===..-'   =  --.  

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 Mid-Central USA 1996

源链接: POJ-1561

最后修改于 2020-10-29T06:07:24+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 10000