P28307 [洛谷] [SCOI2013] Password
提高+
题目描述

Problem Description

Fish is a fish living in the sea. One day, he got bored and decided to go treasure hunting. He found a palace deep in the ocean, but a door with a password lock prevented him from proceeding.

By consulting ancient texts, Fish learned about the password's details:

  1. The password has a length of N.
  2. The password consists only of lowercase letters.
  3. The length of the longest palindrome centered at each character.
  4. The length of the longest palindrome centered at each gap between two adjacent characters.

Fish quickly realized that there might be countless passwords that meet these conditions. After analyzing, he believed that the password with the smallest lexicographical order was most likely the correct one. Can you help him find this password?

Note: For two strings A and B, if their first i characters are identical, and the (i+1)-th character of A is smaller than that of B, then A is considered to have a smaller lexicographical order than B. For example, the string "abc" has a smaller lexicographical order than "acb". If password A has a smaller lexicographical order than all other passwords that meet the conditions, then A is the password with the smallest lexicographical order.

Input Format

The input consists of three lines. The first line contains a single integer N, indicating the length of the password. The second line contains N integers, representing the lengths of the longest palindromes centered at each character. The third line contains N - 1 integers, representing the lengths of the longest palindromes centered at each gap between two adjacent characters.

Output Format

Output a single line. Print the password that meets the conditions with the smallest lexicographical order. The information in the ancient texts is always correct, so there is always a password that meets the conditions.

Sample Input and Output

Sample Input #1

3
1 1 1
0 0

Sample Output #1

abc

Sample Input #2

3
1 3 1
0 0

Sample Output #2

aba

Sample Input #3

3
1 3 1
2 2

Sample Output #3

aaa

Notes

For 20% of the data, 1 <= N <= 100.

For another 30% of the data, 1 <= N <= 1000.

For the last 50% of the data, 1 <= N <= 10^5.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 1 1 1 0 0
样例输出
abc