#P9670. [ICPC2022 Jinan R] Frozen Scoreboard

[ICPC2022 Jinan R] Frozen Scoreboard

题目描述

There was an ICPC contest two thousand years ago in the Qin dynasty. There were mm problems and nn teams in the contest. We only know how many problems each team solved and how much total time they used from the historical records. These are called the final result\textbf{final result}s of the teams. We don't know which problems they solved or their submission times.

Recently, we seem to had a discovery. We found the frozen scoreboard\textbf{frozen scoreboard} of the teams. From the frozen scoreboard of a team, we know their submissions during the whole contest, but we don't know the verdicts of the submissions in the last hour. And some people found that for some teams, their frozen scoreboards may contradict their final results in the historical records.

Given the final results and the frozen scoreboards of the teams, please construct a final scoreboard\textbf{final scoreboard} for each team that is consistent with both its final result and its frozen scoreboard.

From the submissions during the contest, we can calculate the final scoreboard and the final result as follows:

For a fixed team ii, its final scoreboard\textbf{final scoreboard} is an array of mm elements where the jj-th element shows some information about team ii's submissions on problem jj.

  • If team ii didn't submit to problem jj, the cell should be a single character . (without quotes).

  • If team ii submitted xx times to problem jj and none of the submissions was accepted, the cell should contain  x-\ x.

  • Otherwise, consider all submissions from team ii to problem jj. Each submission has a submission time. Suppose the earliest accepted submission is the xx-th one. Then the cell should contain + x/y+\ x/y where y (0y299)y~(0\le y\le 299) is the submission time of the xx-th submission. yy is an integer representing the submission time in minutes.

Note that in the final scoreboard, we don't care about submissions after the first accepted one. It is possible that two or more submissions happened in the same minute.

The final result\textbf{final result} of a team is computed from its final scoreboard\textbf{final scoreboard}. For each team, we can calculate the number of problems it solved. This number is equal to the number of + in the team's final scoreboard.

We can also calculate its total time. If team ii solved problem jj in the yy-th minute after x1x-1 unaccepted submissions (in other words, the jj-th cell of its final scoreboard is + x/y+\ x/y), problem jj contributes 20(x1)+y20(x-1)+y time to team ii. If team ii didn't solve problem jj, problem jj contributes 00 time to team ii, no matter team ii submitted to problem jj or not. The total time of team ii is the sum of contributions of each problem.

The rules for the frozen scoreboard\textbf{frozen scoreboard} will be introduced in the input section. We will distinguish submissions in the final hour and other submissions. A submission was in the final hour if its submission time is between 240240 and 299299.

输入格式

The first line contains two integers n,m (1n1000,1m13)n, m~(1\le n\le 1000, 1\le m\le 13), the number of teams in the contest, and the number of problems in the contest.

Then there are nn blocks describing the final result\textbf{final result} and the frozen scoreboard\textbf{frozen scoreboard} of each team.

The ii-th block represents team ii. In the ii-th block, the first line contains two integers ai,bi (0aim,0bi105)a_i, b_i~(0\le a_i\le m, 0\le b_i\le 10^5), the number of problems team ii solved during the whole contest\textbf{during the whole contest} and the total time of team ii for solving the aia_i problems. These two numbers represent the final result of the contest. The next mm lines describe the status of team ii in the frozen scoreboard. For each 1jm1\le j\le m,

  • If the jj-th line is + x/y+\ x/y (1x100,0y239)(1\le x\le 100, 0\le y\le 239), team ii solved problem jj at time yy and the accepted solution is their xx-th submission on problem jj.
  • If the jj-th line is ? x y?\ x\ y (1xy100)(1\leq x \leq y \leq 100), team ii didn't solve the problem jj in the first four hours. Team ii submitted problem jj for yy times in which xx submissions are in the last hour. Note that submissions made in the last hour after the accepted one will count in the frozen scoreboard\textbf{frozen scoreboard}, but not in the final scoreboard\textbf{final scoreboard}.
  • If the jj-th line is  x-\ x, team ii didn't solve the problem jj in the first four hours. Team ii submitted problem jj for x (1x100)x~(1\le x\le 100) times before the last hour and did not submit problem jj in the last hour.
  • If the jj-th line is a single character . (without quotes), team ii didn't submit problem jj at all.

输出格式

For each team ii, if its final result contradicts its frozen scoreboard, output No\texttt{No} in one line. Otherwise, output Yes\texttt{Yes} in the first line and then output mm lines, describing a final scoreboard that is consistent with both the final result and the frozen scoreboard of team ii. The jj-th line should contain

  • + x/y+\ x/y (1x100,0y299)(1\le x \le 100, 0\le y \le 299), if the xx-th submission from team ii to problem jj is accepted and is in the yy-th minute of the contest. All submissions from team ii to team jj before the xx-th one was not accepted. Please don't output extra spaces before and after slash /.
  •  x-\ x (1x100)(1\le x\le 100), if team ii submitted to problem jj for xx times and none of the submissions was accepted.
  • .. if team ii didn't submit to problem jj at all.

If there are multiple solutions, output any.

$\textbf{Please note that in the input and the output, there is always a space following each ?, +, and -.}$

1 13
7 951
+ 1/6
? 3 4
+ 4/183
- 2
+ 3/217
.
.
.
+ 2/29
+ 1/91
.
+ 1/22
.
Yes
+ 1/6
+ 2/263
+ 4/183
- 2
+ 3/217
.
.
.
+ 2/29
+ 1/91
.
+ 1/22
.
6 2
1 100
.
? 3 4
2 100
+ 1/1
+ 1/2
0 0
- 5
- 6
2 480
? 100 100
? 100 100
2 480
? 99 100
? 100 100
1 2000
? 100 100
? 100 100
No
No
Yes
- 5
- 6
Yes
+ 1/240
+ 1/240
No
Yes
+ 87/280
- 100

提示

Here is an example of the frozen scoreboard in the first sample.