C - X drawing Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 300

問題文

上下左右に広がる N\times N のマス目があり、最初全てのマスは白く塗られています。このマス目の上から i 行目、左から j 列目のマスを (i,j) で表します。

高橋君は 1 以上 N 以下の整数 A, B を持っており、次のような操作を行います。

  • \max(1-A,1-B)\leq k\leq \min(N-A,N-B) をみたす全ての整数 k について、(A+k,B+k) を黒く塗る。
  • \max(1-A,B-N)\leq k\leq \min(N-A,B-1) をみたす全ての整数 k について、(A+k,B-k) を黒く塗る。

この操作を行った後のマス目について、P\leq i\leq Q かつ R\leq j\leq S をみたす各マス (i,j) がそれぞれ何色で塗られているか求めてください。

制約

  • 1 \leq N \leq 10^{18}
  • 1 \leq A \leq N
  • 1 \leq B \leq N
  • 1 \leq P \leq Q \leq N
  • 1 \leq R \leq S \leq N
  • (Q-P+1)\times(S-R+1)\leq 3\times 10^5
  • 入力は全て整数である。

入力

入力は以下の形式で標準入力から与えられる。

N A B
P Q R S

出力

Q-P+1 行出力せよ。
各行は #. のみからなる長さ S-R+1 の文字列であり、 i 行目の文字列の j 番目の文字が # であることは (P+i-1,R+j-1) が黒く塗られていることを、 . であることは (P+i-1,R+j-1) が白く塗られていることをさす。


入力例 1

5 3 2
1 5 1 5

出力例 1

...#.
#.#..
.#...
#.#..
...#.

1 つめの操作で (2,1), (3,2), (4,3), (5,4)4 マスが、 2 つめの操作で (4,1), (3,2), (2,3), (1,4)4 マスが黒く塗られます。
よって、P=1, Q=5, R=1, S=5 より、上のように出力します。


入力例 2

5 3 3
4 5 2 5

出力例 2

#.#.
...#

操作によって、 (1,1), (1,5), (2,2), (2,4), (3,3), (4,2), (4,4), (5,1), (5,5)9 マスが 黒く塗られます。
P=4, Q=5, R=2, S=5 より、上のように出力します。


入力例 3

1000000000000000000 999999999999999999 999999999999999999
999999999999999998 1000000000000000000 999999999999999998 1000000000000000000

出力例 3

#.#
.#.
#.#

入力が 32 bit 整数型に収まらないことがあることに注意してください。

Score : 300 points

Problem Statement

There is an N\times N grid with horizontal rows and vertical columns, where all squares are initially painted white. Let (i,j) denote the square at the i-th row and j-th column.

Takahashi has integers A and B, which are between 1 and N (inclusive). He will do the following operations.

  • For every integer k such that \max(1-A,1-B)\leq k\leq \min(N-A,N-B), paint (A+k,B+k) black.
  • For every integer k such that \max(1-A,B-N)\leq k\leq \min(N-A,B-1), paint (A+k,B-k) black.

In the grid after these operations, find the color of each square (i,j) such that P\leq i\leq Q and R\leq j\leq S.

Constraints

  • 1 \leq N \leq 10^{18}
  • 1 \leq A \leq N
  • 1 \leq B \leq N
  • 1 \leq P \leq Q \leq N
  • 1 \leq R \leq S \leq N
  • (Q-P+1)\times(S-R+1)\leq 3\times 10^5
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N A B
P Q R S

Output

Print Q-P+1 lines.
Each line should contain a string of length S-R+1 consisting of # and .. The j-th character of the string in the i-th line should be # to represent that (P+i-1, R+j-1) is painted black, and . to represent that (P+i-1, R+j-1) is white.


Sample Input 1

5 3 2
1 5 1 5

Sample Output 1

...#.
#.#..
.#...
#.#..
...#.

The first operation paints the four squares (2,1), (3,2), (4,3), (5,4) black, and the second paints the four squares (4,1), (3,2), (2,3), (1,4) black.
Thus, the above output should be printed, since P=1, Q=5, R=1, S=5.


Sample Input 2

5 3 3
4 5 2 5

Sample Output 2

#.#.
...#

The operations paint the nine squares (1,1), (1,5), (2,2), (2,4), (3,3), (4,2), (4,4), (5,1), (5,5).
Thus, the above output should be printed, since P=4, Q=5, R=2, S=5.


Sample Input 3

1000000000000000000 999999999999999999 999999999999999999
999999999999999998 1000000000000000000 999999999999999998 1000000000000000000

Sample Output 3

#.#
.#.
#.#

Note that the input may not fit into a 32-bit integer type.