poj2643 Election (map)
来源:互联网 发布:网络电视直播在线 编辑:程序博客网 时间:2024/06/02 06:01
题目:http://poj.org/problem?id=2643
Output
Output consists of a single line containing one of:
- The name of the party with whom the winning candidate is associated, if there is a winning candidate and that candidate is associated with a party.
- The word "independent" if there is a winning candidate and that candidate is not associated with a party.
- The word "tie" if there is no winner; that is, if no candidate receives more votes than every other candidate.
Sample Input
3Marilyn MansonRhinocerosJane DoeFamily CoalitionJohn Smithindependent6John SmithMarilyn MansonMarilyn MansonJane DoeJohn SmithMarilyn Manson
Sample Output
Rhinoceros
题意:
有n个候选人,每个人有两行数据,第一行为姓名 ,第二行为所属党派。
有m张选票,每张一行,代表所投的候选人的姓名,若所投的姓名不在上述名单中,应忽略。
若有唯一的人胜选,输出其所属党派,若多人同时获最高票,输出“tie”.
#include<stdio.h>#include<string.h>#include<map>#include<iostream>using namespace std;int main(){ int n,m; char name[100]; char party[100]; scanf("%d",&n); getchar(); map<string ,string > name1; map<string ,int > name2; while(n--) { gets(name); gets(party); name1[name]=party; } scanf("%d",&m); getchar(); int s=0; char ans[100]; int flag=1; while(m--) { gets(name); if(name1[name][0]!='\0')name2[name]++; //判断被投票人的姓名是否在名单中 if(name2[name]>s) { s=name2[name]; strcpy(ans,name); flag=1; } else if(name2[name]==s)flag=0; } if(flag)printf("%s\n",name1[ans].c_str()); else printf("tie\n"); return 0;}
- POJ2643 Election(MAP)
- poj2643 Election (map)
- poj2643 map
- POJ2643-map
- poj2643(map+字典树)
- POJ 2643 Election(map)
- POJ 2643 Election ——STL map
- Election
- Election
- Election Time
- 1967: Election
- Election Time
- Election方法1
- Election方法2
- fjnu 1571 Election
- pku3664 Election Time
- 补缺选举 by-election
- zoj 1854 Election
- Ubuntu使用笔记_root登录
- DirectShow SDK
- SSH-C3P0配置p6spy实现sql参数可见
- struct command
- php在线编辑文件网页
- poj2643 Election (map)
- mdadm简介
- slider控件移动滑块,动态的显示tooltip方法!
- VC常用方法(转载)
- 制作U盘启动CDLinux
- 奶瓶beini系统
- struts2配置
- 打造3D游戏中第一人称视觉效果 - 带可测试源代码下载
- 关于对象