302540: CF490E. Restoring Increasing Sequence
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Restoring Increasing Sequence
题意翻译
**题目描述:** Peter在黑板上写了一个严格递增的正整数序列a1,a2,....,an。Vasil将其中的某些数位改成了问号("?"),每个问号代表一个数位 **输入输出格式**: 输入: 输入文件的第一行是一个正整数n(1<=n<=100000),表示序列的长度。 第2行到第n+1行每行给出一个元素描述序列,每个元素都由数字和"?"组成且不含前导0,每个元素的长度l满足1<=l<=8 输出: 如果存在符合要求的解,在第一行输出一行"YES"(不含引号),接下来的n行输出序列的一种可能的情况,序列必须严格递增,且不能改变原序列中数字的位置和数值(仅改变问号),输出中的所有数据均不能包含前导0。如果有多组解,输出任意一组。 如果不存在符合要求的解,仅输出一行"NO"(不含引号)题目描述
Peter wrote on the board a strictly increasing sequence of positive integers $ a_{1},a_{2},...,a_{n} $ . Then Vasil replaced some digits in the numbers of this sequence by question marks. Thus, each question mark corresponds to exactly one lost digit. Restore the the original sequence knowing digits remaining on the board.输入输出格式
输入格式
The first line of the input contains integer $ n $ ( $ 1<=n<=10^{5} $ ) — the length of the sequence. Next $ n $ lines contain one element of the sequence each. Each element consists only of digits and question marks. No element starts from digit 0. Each element has length from 1 to 8 characters, inclusive.
输出格式
If the answer exists, print in the first line "YES" (without the quotes). Next $ n $ lines must contain the sequence of positive integers — a possible variant of Peter's sequence. The found sequence must be strictly increasing, it must be transformed from the given one by replacing each question mark by a single digit. All numbers on the resulting sequence must be written without leading zeroes. If there are multiple solutions, print any of them. If there is no answer, print a single line "NO" (without the quotes).
输入输出样例
输入样例 #1
3
?
18
1?
输出样例 #1
YES
1
18
19
输入样例 #2
2
??
?
输出样例 #2
NO
输入样例 #3
5
12224
12??5
12226
?0000
?00000
输出样例 #3
YES
12224
12225
12226
20000
100000