#abc230c. C - X drawing

C - X drawing

Score : 300300 points

问题描述

存在一个 N×NN\times N 的网格,其中包含水平行和垂直列,所有方格最初都被涂成白色。令 (i,j)(i,j) 表示第 ii 行第 jj 列的方格。

Takahashi 拥有两个整数 AABB,它们都在 11NN(包括两端点)之间。他将执行以下操作:

  • 对于每一个满足 max(1A,1B)kmin(NA,NB)\max(1-A,1-B)\leq k\leq \min(N-A,N-B) 的整数 kk,将 (A+k,B+k)(A+k,B+k) 涂成黑色。
  • 对于每一个满足 max(1A,BN)kmin(NA,B1)\max(1-A,B-N)\leq k\leq \min(N-A,B-1) 的整数 kk,将 (A+k,Bk)(A+k,B-k) 涂成黑色。

在这些操作之后,请找出网格中方格 (i,j)(i,j) 的颜色,条件是 PiQP\leq i\leq QRjSR\leq j\leq S

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

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

Takahashi has integers AA and BB, which are between 11 and NN (inclusive). He will do the following operations.

  • For every integer kk such that max(1A,1B)kmin(NA,NB)\max(1-A,1-B)\leq k\leq \min(N-A,N-B), paint (A+k,B+k)(A+k,B+k) black.
  • For every integer kk such that max(1A,BN)kmin(NA,B1)\max(1-A,B-N)\leq k\leq \min(N-A,B-1), paint (A+k,Bk)(A+k,B-k) black.

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

Constraints

  • 1N10181 \leq N \leq 10^{18}
  • 1AN1 \leq A \leq N
  • 1BN1 \leq B \leq N
  • 1PQN1 \leq P \leq Q \leq N
  • 1RSN1 \leq R \leq S \leq N
  • (QP+1)×(SR+1)3×105(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:

NN AA BB

PP QQ RR SS

Output

Print QP+1Q-P+1 lines.
Each line should contain a string of length SR+1S-R+1 consisting of # and .. The jj-th character of the string in the ii-th line should be # to represent that (P+i1,R+j1)(P+i-1, R+j-1) is painted black, and . to represent that (P+i1,R+j1)(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)(2,1), (3,2)(3,2), (4,3)(4,3), (5,4)(5,4) black, and the second paints the four squares (4,1)(4,1), (3,2)(3,2), (2,3)(2,3), (1,4)(1,4) black.
Thus, the above output should be printed, since P=1P=1, Q=5Q=5, R=1R=1, S=5S=5.

Sample Input 2

5 3 3
4 5 2 5

Sample Output 2

#.#.
...#

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

Sample Input 3

1000000000000000000 999999999999999999 999999999999999999
999999999999999998 1000000000000000000 999999999999999998 1000000000000000000

Sample Output 3

#.#
.#.
#.#

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

update @ 2024/3/10 10:03:12