比赛 NOIP2017普及组模拟赛Mike 评测结果 AAAAA
题目名称 zht 最终得分 100
用户昵称 ユッキー 运行时间 0.002 s
代码语言 C++ 内存使用 0.31 MiB
提交时间 2017-09-29 21:40:25
显示代码纯文本
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <list>
#include <vector>
#include <ctime>
#include <functional>
#define pritnf printf
#define scafn scanf
#define For(i,j,k) for(int i=(j);i<=(k);(i)++)
#define Clear(a,b) memset(a,0,sizeof(a))
using namespace std;
typedef long long LL;
typedef unsigned int Uint; 
const int INF=0x7ffffff;
map <string,string> elected;
map <string,int> ShowTime;
map <string,int> ticket;
string str;
int main()
{  
  freopen("zht1.in","r",stdin);
    freopen("zht1.out","w",stdout);
      int T=0;
        while (getline(cin,str)){
            T++;
            int pos=str.find(':');
                string submiter=str.substr(0,pos);
                    string candidate=str.substr(pos+1,str.length()-pos-1);
                        ticket[candidate]++;
                            if (ShowTime[candidate]==0){
                                  ShowTime[candidate]=T;
                                  elected[candidate]=submiter;
                                }
          }
  map <string,int>::iterator it,endit=ticket.end();
    string sub,cand;
      int maxt=0,firstt=INF;
        for(it=ticket.begin();it!=endit;++it){
            if (maxt<it->second){
                  maxt=it->second;
                  firstt=INF;
                }
            if (maxt==it->second&&ShowTime[it->first]<firstt){
                  firstt=ShowTime[it->first];
                  sub=elected[it->first];
                  cand=it->first;
                }
          }
  cout<<sub<<endl<<cand<<endl;
  return 0;
}