#P9670. [ICPC2022 Jinan R] Frozen Scoreboard

    ID: 8967 Type: RemoteJudge 2000ms 512MiB Tried: 0 Accepted: 0 Difficulty: 4 Uploaded By: Tags>2022Special JudgeO2优化ICPC

[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 -.}$

题目大意

题目描述

2000 年以前的秦朝,曾举办过一次 ICPC 比赛。比赛中有 mm 道题,nn 个团队。我们知道每个队完成了多少道题以及其历史记录的总用时。这些称作该团队的结果,但是我们不知道他们每道题是否完成、用时多久。

最近,我们发现了每个队冻结的计分板。从该计分板上,我们可以看到每个队在比赛中的提交情况,但是不知道在最后一小时内提交的判分。一些人发现,对于一些队来说,他们冻结的计分板可能与他们在历史记录中的最终成绩相矛盾。

请根据最终得分和冻结的计分板,为各队创建一个与其最终结果和冻结的计分板一致的最终计分板。

按照以下规则来计算计分板和总分:

对于给定的队伍 ii,它最终的计分板是一个 mm 元数组,其中第 jj 个元素给出队伍 ii 在第 jj 题上的提交信息。

  • 如果队伍 ii 没有提交问题 jj,输出 .

  • 如果队伍 ii 对问题 jj 提交了 xx 次但均未通过,输出 x-x

  • 否则,考虑队伍 ii 在问题 jj 的所有评测结果。每次提交都有一个提交时间,设第一个通过的评测是第 xx 次评测,在第 yy 分钟时提交。输出 +x/y+x/y,其中 0y2990\leq y\leq299

在最终计分板上,只考虑第一次通过的提交。同一分钟内可能有多次提交。

一个队伍的最终得分是该队伍完成了多少道题,即该队最终计分板上 + 的个数。

一个队伍总用时按如下方式计算。如果队伍 ii 在第 yy 分钟完成了第 jj 道题,在完成前有 x1x-1 次失败的提交(即最终计分板上第 jj 个问题的数为 +x/y+x/y),该问题的用时记为 20(x1)+y20(x-1)+y。 如果队伍 ii 没有完成第 jj 道题,该问题的用时记为 00,无论是否提交过。队伍 ii 的总时间是每道题用时的总和。

输入格式

第一行包括两个整数 n,m  (1n1000,1m13)n,m\;(1\leq n\leq1000,1\leq m\leq13),为队伍个数和题目个数。

接下来 nn 组,描述每个队伍的最终得分和冻结的计分板。

ii 组表示队伍 ii。每一组中,第一行包括两个整数 ai,bi  (0aim,0bi105)a_i,b_i\;(0\leq a_i\leq m,0\leq b_i\leq10^5),为队伍 ii整场比赛中完成的题目个数和每道题的用时。这两个数字是比赛的最终结果。

接下来 mm 行,描述队伍 ii 在计分板上的内容。对于任意 1jm1\leq j\leq m

  • 如果第 jj 行是 +x/y  (1x100,0y239)+\,x/y\;(1\leq x\leq100,0\leq y\leq239),表示队伍 ii 在第 yy 分钟,第 xx 次提交时通过了题 jj

  • 如果第 jj 行是 ?xy  (1xy100)?\,x\,y\;(1\leq x\leq y\leq100),表示队伍 ii 没有在前四个小时中作出题 jj。这个队伍提交了 yy 次,其中 xx 次在最后一小时内。最后一小时内且通过该题的提交记录会在冻结的计分板上显示,但不会在最终计分板上显示。

  • 如果第 jj 行是 x-x,表示队伍 ii 没有在前四小时内作出题 jj。这个队伍在最后一个小时前提交了 x(1x100)x\,(1\leq x\leq100) 次,且没有在最后一小时内做出题 jj

  • 如果第 jj 行是一个单一的字符 .,表示队伍 ii 没有提交过题 jj

输出格式

对于每个队伍 ii,如果最终结果和冻结的计分板相矛盾,输出一行 No\texttt{No}。否则,第一行输出 Yes\texttt{Yes},接下来 mm 行,描述一种队伍 ii 可能的计分板,满足最终结果和冻结的计分板。其中,第 jj 行应该包括:

  • +x/y(1x100,0y299)+\,x/y\,(1\leq x\leq100,0\leq y\leq299),如果队伍 ii 在第 xx 次提交,第 yy 分钟完成了题 jj,在这之前没有队伍通过这道题。不要在字符 / 前后输出多余的空格。

  • x(1x100)-x\,(1\leq x\leq100),如果队伍 ii 提交了 xx 次题 jj,且均未通过。

  • .,如果队伍 ii 没有提交题 jj

如果有多种可能的答案,任意输出一种即可。

请注意,在输入和输出中,?,+,- 后总有一个空格。

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.