102302: [AtCoder]ABC230 C - X drawing

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

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.

Input

题意翻译

给定一个$N*N$的格点,给定两个整数 A,B 做以下两个操作: 对每个整数 $k$ 满足 $max(1-A,1-B) \le k \le min(N-A,N-B)$,将 $(A+k,B+k)$ 涂成黑色 对每个整数 $k$ 满足 $max(1-A,B-N) \le k \le min(N-A,B-1)$,将 $(A+k,B-k)$ 涂成黑色 然后给定一个子区域 $P \le i \le Q ,R \le j \le S $需要输出这个子区域的涂色情况

Output

分数:300分 部分 问题描述 有一个N×N的网格,有水平行和垂直列,其中所有的方块最初都是白色的。让(i,j)表示第i行和第j列的方块。 Takahashi有整数A和B,它们在1和N(包括)之间。他将执行以下操作。 对于所有满足$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≤i≤Q和R≤j≤S的每个方块(i,j)的颜色。 部分 约束条件 1≤N≤1018 1≤A≤N 1≤B≤N 1≤P≤Q≤N 1≤R≤S≤N (Q-P+1)×(S-R+1)≤3×105 输入中的所有值都是整数。 输入 从标准输入以以下格式给出输入: 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)是白色的。

加入题单

算法标签: