luogu#P7080. [NWRRC2013] Ballot Analyzing Device

[NWRRC2013] Ballot Analyzing Device

题目描述

Election committee of Flatland is preparing for presidential elections. To minimize human factor in ballot counting they decided to develop an automated Ballot Analyzing Device (BAD).(BAD).

There are nn candidates running for president. The ballot contains one square field for each candidate. The voter must mark exactly one of the fields. If no field is marked or there are two or more marked fields, the ballot is invalid. Each voter puts his/herhis/her ballot to a special scanner in BAD. The scanner analyzes marks on the ballot and creates a special voting string of nn characters: X‘X' for marked field and .‘. ' for unmarked one. Now voting strings must be analyzed to get the report. Your task is to develop a report generator for BAD.

Given voting strings for all ballots, your program must print the voting report. Candidates in the report must be arranged in order of decreasing number of votes. If two candidates have the same number of votes, they must have the same order as in a voting ballot. For each candidate calculate his/herhis/her result in percent (if the candidate received pp votes, the result in percent is 100p/m)100p/m) . The last line of the report must indicate the percentage of the invalid ballots.

输入格式

The first line contains two integers nn and mm -- the number of candidates and the number of ballots (2n10(2 \le n \le 10 ; 1m1000)1 \le m \le 1000) . The following nn lines contain last names of candidates. Each name is a string of at most 100100 English letters. There is no candidate named Invalid.

Then mm lines follow, each of them contains one voting string.

输出格式

Print n+ 11 lines. First print results for candidates in percent. For each candidate print his/herhis/her last name followed by a space and then his/herhis/her result in percent and a percent sign %.‘\%'. The last line must specify the percentage of invalid ballots: a word Invalid followed by a space, the percentage of invalid ballots and a percent sign.

Round all numbers to exactly two digits after the decimal point. If the number is exactly in the middle of two representable numbers, output the greater one (e.g . output 12 . $35$ for 1212 . 345345) .

题目大意

nn 名选手参加一个比赛,有 mm 个人为他们投票。第 ii 个人的投票情况用一个长度为 nn,并且仅包含 .X 两个字符的字符串,其中,如果第 jj 位是 X,则第 ii 个人将票投给了第 jj 名选手,否则没有。规定每个投票者能且仅能将票投给一个人,否则都算无效票(即投的票数 2\geqslant 2 或者 =0=0)。请将每名选手按照他们所得到的票的比例排序(如果有两名选手得到的票的比例相同,在投票次序中先出现的那名选手排在前面),并输出他们的名字和得票比例,最后还要输出无效票所占的比例。

Translated by Eason_AC
2020.11.12

4 7
Loudy
Apples
Dogman
Miller
.X..
X...
....
..X.
..XX
..X.
..X.

Dogman 42.86%
Loudy 14.29%
Apples 14.29%
Miller 0.00%
Invalid 28.57%

提示

Time limit: 2 s, Memory limit: 256 MB.