atcoder#ARC132A. [ARC132A] Permutation Grid
[ARC132A] Permutation Grid
Score : points
Problem Statement
Given are two permutations of : and .
We have a grid with horizontal rows and vertical columns. You will paint each square black or white to satisfy the following conditions.
- For each , the -th row from the top has exactly black squares.
- For each , the -th column from the left has exactly 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 queries .
For each , print #
if the square at the -th row from the top and -th column from the left is painted black; print .
if that square is painted white.
Constraints
- and are each permutations of .
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print a string of length whose -th character is the answer to the -th query.
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
#.#.#.#
The conditions are satisfied by painting the grid as follows.
#####
#...#
#.#.#
###.#
....#