Ballot Analyzing Device

题目连接:

http://codeforces.com/gym/100269/attachments

Description

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).

There are n 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/her ballot to a special scanner in BAD. The scanner

analyzes marks on the ballot and creates a special voting string of n characters: ‘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/her result

in percent (if the candidate received p votes, the result in percent is 100p/m). The last line of the report

must indicate the percentage of the invalid ballots.

Input

The first line contains two integers n and m — the number of candidates and the number of ballots

(2 ≤ n ≤ 10; 1 ≤ m ≤ 1000). The following n lines contain last names of candidates. Each name is a

string of at most 100 English letters. There is no candidate named “Invalid”.

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

Output

Print n+ 1 lines. First print results for candidates in percent. For each candidate print his/her last name

followed by a space and then his/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 12.345).

Sample Input

4 7

Loudy

Apples

Dogman

Miller

.X..

X...

....

..X.

..XX

..X.

..X.

Sample Output

Dogman 42.86%

Loudy 14.29%

Apples 14.29%

Miller 0.00%

Invalid 28.57%

Hint

题意

有m个人给n个人投票,每个人最多给一个人投票,如果投了两个人或者没有投票的话,那么这张票就算无效

然后让你按照票数高低排序,如果票数相同,就按照一开始的顺序输出

题解:

模拟题,当然也是水题

代码

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1050;
char s[maxn];
pair<int,pair<int,string> > p[maxn];
int main()
{
freopen("bad.in","r",stdin);
freopen("bad.out","w",stdout);
int n,m;
scanf("%d%d",&n,&m);
int t=0;
for(int i=0;i<n;i++)
cin>>p[i].second.second,p[i].second.first=n-i;
for(int i=0;i<m;i++)
{
scanf("%s",s);
int flag = 0,cnt = 0;
for(int j=0;j<n;j++)
{
if(s[j]=='X')
flag=j,cnt++;
}
if(cnt==0||cnt>1)
t++;
else
p[flag].first++;
}
sort(p,p+n);
for(int i=n-1;i>=0;i--)
{
cout<<p[i].second.second<<" ";
printf("%.2f%%\n",100.0*p[i].first/m);
}
printf("Invalid %.2f%%\n",100.0*t/m);
}

Codeforces Gym 100269B Ballot Analyzing Device 模拟题的更多相关文章

  1. Codeforces Gym 100269A Arrangement of Contest 水题

    Problem A. Arrangement of Contest 题目连接: http://codeforces.com/gym/100269/attachments Description Lit ...

  2. Gym 100646 Problem C: LCR 模拟题

    Problem C: LCR 题目连接: http://codeforces.com/gym/100646/attachments Description LCR is a simple game f ...

  3. Educational Codeforces Round 2 A. Extract Numbers 模拟题

    A. Extract Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/600/pr ...

  4. Codeforces Beta Round #3 C. Tic-tac-toe 模拟题

    C. Tic-tac-toe 题目连接: http://www.codeforces.com/contest/3/problem/C Description Certainly, everyone i ...

  5. Codeforces Gym 100463B Music Mess Hash 逻辑题

    Music Mess Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100463/attachments ...

  6. codeforces Gym 100187H H. Mysterious Photos 水题

    H. Mysterious Photos Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/p ...

  7. codeforces Gym 100500H H. ICPC Quest 水题

    Problem H. ICPC QuestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/a ...

  8. Codeforces Gym 100513F F. Ilya Muromets 水题

    F. Ilya Muromets Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513/probl ...

  9. HNU 12845 Ballot Analyzing Device

    题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12845&courseid=270 解题报告:有m个认给 ...

随机推荐

  1. 基于Android的简单聊天工具-服务器端

    1.数据库用的mysql,一共有3张表,一张用户表user.一张朋友列表friend和一张消息表message. 1 User table 用户表 uid 主键自动生成 userName 昵称 use ...

  2. 调试应用程序(Debugging Applications)

    调试应用程序(Debugging Applications)¶ Phalcon中提供了提供了几种调试级别即通知,错误和异常. 异常类 Exception class 提供了错误发生时的一些常用的调试信 ...

  3. ARM中断向量表与响应流程【转】

    转自:http://blog.csdn.net/honour2sword/article/details/40213417 一首先中断向量表定义在哪里?如何加载? 二 中断向量表与中断服务程序 三处理 ...

  4. 关于aspxgridview里面过长内容只显示的一部分的处理方案

    protected void g_Message_CustomColumnDisplayText(object sender, ASPxGridViewColumnDisplayTextEventAr ...

  5. ansible安装和配置

    一.安装ansible准备 //安装准备 .两台机器 172.7.15.106 172.7.15.111 .设置hostname以及hosts 172.7.15.106 web9.lulu.com 1 ...

  6. FS Shell命令

    HDFS命令基本格式 hadoop fs -cmd args hdfs dfs -cmd args cat hadoop fs -cat URI [URI .....] 将路径指定文件的内容输出到st ...

  7. python 几种循环性能测试: while, for, 列表生成式, map等

    直接上代码: #!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2018/07/24 16:23 import itertools imp ...

  8. 2017-2018 ACM-ICPC Northern Eurasia (Northeastern European Regional) Contest (NEERC 17) 日常训练

    A - Archery Tournament 题目大意:按时间顺序出现靶子和射击一个位置,靶子的圆心为(x, y)半径为r,即圆与x轴相切,靶子不会重叠,靶子被击中后消失, 每次射击找出哪个靶子被射中 ...

  9. 将xml文件转为c#对像

    读取xml文件数据,通过序列化反序列化转为List<T>对象后,对对象进行操作.

  10. Chrome浏览器你可以选择知道的知识

    Chrome浏览器我想是每一个前端er必用工具之一吧,一部分原因是它速度快,体积不大,支持的新特性也比其它浏览器多,还有一部分我想就是因为它的控制台功能强大了吧,说它是神器一点也不过分,很方便.但其实 ...