编程介的小学生 2017-09-18 08:57 采纳率: 20.5%
浏览 671
已采纳

Divide et unita

Description

A polyomino is a two-dimensional figure formed from several squares with adjacent sides so that all the squares of polyomino can be visited by the rook moving each turn from one square belonging to the figure to its vertical or horizontal neighbour, also belonging to the figure.

On an infinite squared paper sheet N^2 squares are marked (2<=N<=5) that forms a polyomino P. You should write a program that divides this polyomino into two other polyominos, A and B, wherefrom using rotations and parallel translations (mirror reflection is not allowed), it is possible to assemble a square N*N. Only one of the possible solutions should be found.
Input

The input file will contain an image of a part of the sheet that contains the polyomino P, represented by the characters '.' (dot) denoting empty spaces and '*' (asterisk) denoting squares that belong to the figure (because it is impossible to put infinite squared sheet in a file, the input file describes only part of it; all the omitted squares are considered empty). There will be no other characters in the lines of the input file. The input file will not contain lines that are longer than 100 characters and there will be no more than 100 lines. There will be always at least one solution for the given input file.
Output

Echo the image of the given part of sheet with polyomino into the output file replacing each asterisk with characters 'A' or 'B' in accordance with which of polyominos (parts), A or B, this square belongs to. The output file should contain the same lines with the same order except for the above described changes.
Sample Input

..
......
....*.
..*.*
..***
..****
..*..*
..****
.......
Sample Output

..
......
....B.
..B.B
..BBB
..AABA
..A..A
..AAAA
.......

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-10-02 15:47
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序