比赛 NOIP2017普及组模拟赛Mike 评测结果 AAAAA
题目名称 zht 最终得分 100
用户昵称 路人甲 运行时间 0.003 s
代码语言 C++ 内存使用 1.46 MiB
提交时间 2017-09-29 21:31:31
显示代码纯文本
  1. #include <cstdio>
  2. #include <iostream>
  3. #include <map>
  4. #include <string>
  5. #include <cstring>
  6. #include <algorithm>
  7. using namespace std;
  8. char s[1000];
  9. string a,b,ans1="",ans2="";
  10. int ansm=0;
  11. map<string,int> q;
  12. int tt[100010];
  13. string fa[100010],to[100010];
  14. int e=0;
  15. int main(){
  16. freopen("zht1.in","r",stdin);
  17. freopen("zht1.out","w",stdout);
  18. while (gets(s)&&s[0]!='/0'){
  19. int i=0;
  20. a="";
  21. b="";
  22. for (;i<strlen(s);++i){
  23. if (s[i]==':') break;
  24. a=a+s[i];
  25. }
  26. for (++i;i<strlen(s);++i){
  27. b=b+s[i];
  28. }
  29. if (q[b]==0) {
  30. q[b]=++e;
  31. tt[e]=1;
  32. fa[e]=a;
  33. to[e]=b;
  34. }
  35. else ++tt[q[b]];
  36. }
  37. /*for (map<string,pair<int,string> >::iterator i=q.begin();i!=q.end();++i){
  38. if (i->second.first>ansm){
  39. ansm=i->second.first;
  40. ans1=i->second.second;
  41. ans2=i->first;
  42. }
  43. }*/
  44. for (int i=1;i<=e;++i){
  45. if (tt[i]>ansm){
  46. ansm=tt[i];
  47. ans1=fa[i];
  48. ans2=to[i];
  49. }
  50. }
  51. cout<<ans1<<endl<<ans2;
  52. return 0;
  53. }
  54.