/
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 266 点
問題文
高橋君は、情報の授業で使う教材として、穴あきカードを作成しています。
穴あきカードは N \times M のグリッド状になっており、各マスには穴が開いているか、開いていないかのどちらかです。穴が開いているマスを .、開いていないマスを # として図を描くことにしました。
高橋君は最初、どのマスにも穴が開いていないカード(すべてのマスが #)を用意しました。その後、青木君の指示に従って、K 箇所に穴を開けることにしました。
青木君が指定した穴の位置は座標 (R_i, C_i) で表されます(1 \leq i \leq K)。ここで、(R_i, C_i) は上から R_i 行目、左から C_i 列目のマスを指します。
青木君の指示通りに穴を開けた後のカードの状態を出力してください。
制約
- 1 \leq N \leq 1000
- 1 \leq M \leq 1000
- 1 \leq K \leq N \times M
- 1 \leq R_i \leq N (1 \leq i \leq K)
- 1 \leq C_i \leq M (1 \leq i \leq K)
- (R_i, C_i) \neq (R_j, C_j) (i \neq j)
- 入力はすべて整数
入力
N M K R_1 C_1 R_2 C_2 : R_K C_K
- 1 行目には、カードの行数を表す N 、列数を表す M 、穴を開ける箇所の個数を表す K が、スペース区切りで与えられる。
- 2 行目から K + 1 行目では、穴を開ける位置が与えられる。
- 1 + i 行目では、 i 番目に穴を開ける位置の行番号 R_i と列番号 C_i がスペース区切りで与えられる。
出力
N 行にわたって、カードの状態を出力せよ。 i 行目には M 文字からなる文字列を出力し、 j 文字目は座標 (i, j) に穴が開いていない場合は #、穴が開いている場合は . とせよ。
入力例 1
3 4 2 1 2 2 3
出力例 1
#.## ##.# ####
入力例 2
5 5 8 1 1 1 5 2 2 2 4 3 3 4 2 4 4 5 1
出力例 2
.###. #.#.# ##.## #.#.# .####
入力例 3
6 10 15 1 3 1 7 2 1 2 5 2 9 3 2 3 6 3 10 4 4 4 8 5 1 5 5 5 10 6 3 6 7
出力例 3
##.###.### .###.###.# #.###.###. ###.###.## .###.####. ##.###.###
Score : 266 pts
Problem Statement
Takahashi is creating punched cards as teaching materials for his information class.
A punched card is arranged in an N \times M grid, where each cell either has a hole punched in it or not. We will draw a diagram using . for cells with holes and # for cells without holes.
Takahashi initially prepared a card with no holes in any cell (all cells are #). After that, following Aoki's instructions, he decided to punch holes in K locations.
The positions of the holes specified by Aoki are represented by coordinates (R_i, C_i) (1 \leq i \leq K). Here, (R_i, C_i) refers to the cell in the R_i-th row from the top and the C_i-th column from the left.
Output the state of the card after punching holes according to Aoki's instructions.
Constraints
- 1 \leq N \leq 1000
- 1 \leq M \leq 1000
- 1 \leq K \leq N \times M
- 1 \leq R_i \leq N (1 \leq i \leq K)
- 1 \leq C_i \leq M (1 \leq i \leq K)
- (R_i, C_i) \neq (R_j, C_j) (i \neq j)
- All inputs are integers
Input
N M K R_1 C_1 R_2 C_2 : R_K C_K
- The first line contains N representing the number of rows of the card, M representing the number of columns, and K representing the number of locations to punch holes, separated by spaces.
- From the 2nd line to the (K + 1)-th line, the positions to punch holes are given.
- The (1 + i)-th line contains the row number R_i and column number C_i of the i-th hole position, separated by a space.
Output
Output the state of the card over N lines. The i-th line should contain a string of M characters, where the j-th character is # if there is no hole at coordinate (i, j), and . if there is a hole.
Sample Input 1
3 4 2 1 2 2 3
Sample Output 1
#.## ##.# ####
Sample Input 2
5 5 8 1 1 1 5 2 2 2 4 3 3 4 2 4 4 5 1
Sample Output 2
.###. #.#.# ##.## #.#.# .####
Sample Input 3
6 10 15 1 3 1 7 2 1 2 5 2 9 3 2 3 6 3 10 4 4 4 8 5 1 5 5 5 10 6 3 6 7
Sample Output 3
##.###.### .###.###.# #.###.###. ###.###.## .###.####. ##.###.###