To help design the new gas pipeline which will be used to deliver Russian gas to Croatia, Zagreb and Moscow are using the computer game Pipe Mania. In the game, Europe is divided into R rows and C columns. Each cell can be empty or contain one of the seven basic pipeline building blocks:
Gas flows from Moscow to Zagreb. Gas can flow in either direction through the building blocks. Block '+' is special in that gas must flow in two directions (one vertical, one horizontal), as in the following example:
Work on the new pipeline had already started when it was found that malicious hackers got hold of the plan and erased exactly one building block from the plan i.e. replaced it with an empty cell.
Write a program that determines where the block was erased from and what type it was.
The input will be such that a solution will exist and it will be unique.
input 3 7 ....... .M-.-Z. ....... output 2 4 - input 3 5 ..1-M 1-+.. Z.23. output 2 4 4 input 6 10 Z.1----4.. |.|....|.. |..14..M.. 2-+++4.... ..2323.... .......... output 3 3 |
출처:coci/2008-2009/regional