ACM-ICPC World Finals 2017 G

Replicate Replicate Rfplicbte

The owner of the Automatic Cellular Manufacturing corporation has just patented a new process for the mass production of identical parts. Her approach uses a two-dimensional lattice of two-state cells, each of which is either “empty” or “filled.” The exact details are, of course, proprietary.

Initially, a set of cells in the lattice is filled with a copy of the part that is to be reproduced. In a sequence of discrete steps, each cell in the lattice simultaneously updates its state by examining its own state and those of its eight surrounding neighbors. If an odd number of these nine cells are filled, the cell’s state in the next time step will be filled, otherwise it will be empty. Figure 1 shows several steps in the replication process for a simple pattern consisting of three filled cells.

\includegraphics[width=1.0\textwidth ]{fig1}

Figure 1: The replication process.

However, a bug has crept into the process. After each update step, one cell in the lattice might spontaneously flip its state. For instance, Figure 2 shows what might happen if a cell flipped its state after the first time step and another flipped its state after the third time step.

\includegraphics[width=1.0\textwidth ]{fig2}

Figure 2: Errors in the replication process. This figure corresponds to Sample Input 1.

Unfortunately, the original patterns were lost, and only the (possibly corrupted) results of the replication remain. Can you write a program to determine a smallest possible nonempty initial pattern that could have resulted in a given final pattern?

Input

The first line of input contains two integers [Math Processing Error]w ([Math Processing Error]1≤w≤300) and [Math Processing Error]h ([Math Processing Error]1≤h≤300), where [Math Processing Error]w and [Math Processing Error]h are the width and height of the bounding box of the final pattern. Following that are [Math Processing Error]h lines, each containing [Math Processing Error]w characters, giving the final pattern. Each character is either ‘.’  (representing an empty cell) or ‘#’ (representing a filled cell). There is at least one filled cell in the first row, in the last row, in the first column, and in the last column.

Output

Display a minimum-size nonempty pattern that could have resulted in the given pattern, assuming that at each stage of the replication process at most one cell spontaneously changed state. The size of a pattern is the area of its bounding box. If there is more than one possible minimum-size nonempty starting pattern, any one will be accepted. Use the character ‘.’ for empty cells and ‘#’ for filled cells. Use the minimum number of rows and columns needed to display the pattern.

Sample Input 1Sample Output 1
10 10
.#...#...#
##..##..##
##.#.##...
##.#.##...
.#...#####
...##..#.#
......###.
##.#.##...
#..#..#..#
##..##..##
.#
##
Sample Input 2Sample Output 2
8 8
##..#.##
#.####.#
.#.#.#..
.##.#.##
.#.#.#..
.##.#.##
#..#.###
##.#.##.
####
#..#
#.##
###.
Sample Input 3Sample Output 3
5 4
#....
..###
..###
..###
#
阅读更多

ACM-ICPC World Finals 2007 排名

03-15

Rank Name Solved Time rn1 Warsaw University 8 1405 rn2 Tsinghua University 7 1200 rn3 St. Petersburg University of IT, Mechanics and Optics 6 866 rn4 Massachusetts Institute of Technology 6 866 rn5 Novosibirsk State University 6 868 rn6 Saratov State University 6 957 rn7 Twente University 6 1011 rn8 Shanghai Jiao Tong University 6 1026 rn9 University of Waterloo 6 1103 rn10 Moscow State University 6 1192 rn11 University of Auckland 6 1210 rn12 California Institute of Technology 6 1241 rn13 Petrozavodsk State University 6 rn14 Kyoto University 5 rn14 National Taiwan University 5 rn14 Peking University 5 rn14 Seoul National University 5 rn14 Sharif University of Technology 5 rn14 St. Petersburg State University 5 rn14 Universidad de Buenos Aires 5 rn14 University of Alberta 5 rn14 University of British Columbia 5 rn14 University of Science and Technology of China 5 rn14 University of Texas at Dallas 5 rn14 University of Toronto 5 rn26 Amirkabir University of Technology 4 rn26 Belarusian State University 4 rn26 Fudan University 4 rn26 Johannes Kepler Universität Linz 4 rn26 KTH - Royal Institute of Technology 4 rn26 National Technical University of Ukraine 4 rn26 Pontifícia Universidade Católica do Rio de Janeiro 4 rn26 Stanford University 4 rn26 Stavropol State University 4 rn26 The University of Tokyo 4 rn26 Universidade de São Paulo 4 rn26 University of Cape Town 4 rn26 University of Illinois at Urbana-Champaign 4 rn26 University of Nebraska - Lincoln 4 rn26 University of Wroclaw 4 rn26 Ural State University 4 rn26 Vologda State Pedagogical University 4 rn26 Zhongshan (Sun Yat-sen) University 4 rn44 Bina Nusantara University 3 rn44 Carnegie Mellon University 3 rn44 College of Technology, Vietnam National University, Hanoi 3 rn44 Cornell University 3 rn44 Duke University 3 rn44 East China University of Science & Technology 3 rn44 Hefei University of Technology 3 rn44 Indian Institute of Technology, Madras 3 rn44 Korea Advanced Institute of Science and Technology 3 rn44 National University of Defense Technology 3 rn44 Orel State Technical University 3 rn44 Saitama University 3 rn44 Universidad Centroccidental Lisandro Alvarado 3 rn44 Universitat Politècnica de Catalunya 3 rn44 University of Adelaide 3 rn44 University of Bucharest 3 rn44 University of Central Florida 3 rn44 University of New South Wales 3 rn44 Xiamen University 3 rn44 Xidian University 3 rn44 Zhejiang University 3 rnrnHonorable Mention rnArab Academy for Science and Technology The University of Hong Kong rnBangladesh University of Engineering & Technology Universidad Central de Venezuela rnBenemérita Universidad Autónoma de Puebla Universidad Tecnologica de la Mixteca rnHarvard University Universidad de Chile rnIndian Institute of Technology, Bombay Universidade Federal do Rio de Janeiro rnInstituto Tecnologico de Aeronautica University of Calgary rnKazakh National University University of Minnesota rnMercer University University of North Carolina at Chapel Hill rnNanyang Technological University University of Texas at Austin rnNational Institute of Technology, Trichy University of Wisconsin - Madison rnNorthwestern University Vanderbilt University rnRutgers, The State University of New Jersey Virginia Tech rnrnrnRegion Champion rnAfrica and the Middle East University of Cape Town rnAsia Tsinghua University rnEurope Warsaw University rnLatin America Universidad de Buenos Aires rnNorth America Massachusetts Institute of Technology rnSouth Pacific University of Auckland

没有更多推荐了,返回首页