AtCoder Regular Contest 132
A
Permutation Grid
AtCoder
⌀ 347
原题
←B →
翻译中…

Problem Statement

翻译中…

Given are two permutations of $1,\dots,n$: $R_1,\dots,R_n$ and $C_1,\dots,C_n$.

翻译中…

We have a grid with $n$ horizontal rows and $n$ vertical columns. You will paint each square black or white to satisfy the following conditions.

翻译中…
  • For each $i=1,\dots,n$, the $i$-th row from the top has exactly $R_i$ black squares.
  • For each $j=1,\dots,n$, the $j$-th column from the left has exactly $C_j$ black squares.
翻译中…

It can be proved that, under the Constraints of this problem, there is exactly one way to paint the grid to satisfy the conditions.

翻译中…

You are given $q$ queries $(r_1,c_1),\dots,(r_q,c_q)$. For each $i=1,\dots,q$, print # if the square at the $r_i$-th row from the top and $c_i$-th column from the left is painted black; print . if that square is painted white.

翻译中…

Constraints

翻译中…
  • $1\le n,q\le 10^5$
  • $R_1,\dots,R_n$ and $C_1,\dots,C_n$ are each permutations of $1,\dots,n$.
  • $1\le r_i,c_i \le n$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

n
R_1 \dots R_n
C_1 \dots C_n
q
r_1 c_1
\vdots
r_q c_q

翻译中…

Output

翻译中…

Print a string of length $q$ whose $i$-th character is the answer to the $i$-th query.

翻译中…

样例

Input #1
5
5 2 3 4 1
4 2 3 1 5
7
1 5
5 1
1 1
2 2
3 3
4 4
5 5
Output #1
#.#.#.#
The conditions are satisfied by painting the grid as follows.
题目信息
题号
arc132_a
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。