#P15297. [ROI 2012 Day 1] calendar 古代日历

    ID: 17376 远端评测题 1000ms 256MiB 尝试: 0 已通过: 0 显示难度暂无评定 上传者: 标签>2012Special JudgeROI(俄罗斯)

[ROI 2012 Day 1] calendar 古代日历

Background

Translation source: loj #5458. 「ROI 2012 Day 1」Ancient Calendar.

Problem Description

As everyone knows, in 2012 humans showed great interest in ancient calendars. Especially interesting were those calendars that did not end in 2012. Archaeologists in Tatarstan made an amazing discovery in this area. They found a rectangular stone tablet in an ancient tomb. After decoding the preserved symbols, they recorded it as a table with NN rows, each containing MM decimal digits. However, the tablet could not be fully decoded because some digits had been worn away. The missing digits in the table are replaced by the symbol *.

The archaeologists believe that this tablet is an ancient calendar, where the MM digits represent the day number for consecutive days within a certain period. The first digit string is the number of the first day in that period, and each following one is larger than the previous by 11. According to this calendar, the end of the world does not exist: after the day number consisting of MM nines, the next day number is the one consisting of MM zeros.

You need to write a program to restore the missing digits so that, starting from the second row, each number is greater than the number in the previous row by 11, and output the number of the first day in the found calendar.

Input Format

The first line of the input file contains two natural numbers NN and MM $(1 \leq N \leq 100000, 1 \leq M \leq 100000, M \times N \leq 100000)$, representing the number of rows in the table and the length of each row.

The next NN lines each contain MM characters, consisting only of decimal digits 00 to 99 and the symbol *.

Output Format

The output file should contain one line consisting of MM digits, representing the number of the first day in the calendar. If there are multiple ways to restore it, you may output any one. It is guaranteed that at least one restoration exists.

1 2
23

23

3 3
1**
*1*
**1

109

2 3
9**
00*
999
3 4 
****
*0**
01**

0098

Hint

The detailed additional constraints and scores for subtasks are shown in the table below.

Subtask Score Additional Constraints Notes
11 4040 1≤N≤10001 \leq N \leq 1000, 1≤M≤1001 \leq M \leq 100, each column has at least one preserved digit You must pass all test points in this subtask to get the score.
22 3030 1≤N≤10001 \leq N \leq 1000, 1≤M≤1001 \leq M \leq 100, at least one column contains only * Each test point is scored independently.
33 1≤N≤1000001 \leq N \leq 100000, 1≤M≤1000001 \leq M \leq 100000, M×N≤100000M \times N \leq 100000 You must pass all test points in this subtask to get the score.

Translated by ChatGPT 5