英文题目

Zhejiang University is about to celebrate her 122th anniversary in 2019. To prepare for the celebration, the alumni association (校友会) has gathered the ID’s of all her alumni. Now your job is to write a program to count the number of alumni
among all the people who come to the celebration.

Input Specification:
Each input file contains one test case. For each case, the first part is about the information of all the alumni. Given in the first line is a positive integer NNN (≤105).
Then NNN lines follow, each contains an ID number of an alumnus. An ID number is a string of 18 digits or the letter X. It is guaranteed that all the ID’s are distinct.
The next part gives the information of all the people who come to the celebration.
Again given in the first line is a positive integer MMM(≤105). Then MMM lines follow, each contains an ID number of a guest. It is guaranteed that all the ID’s are distinct.

Output Specification:
First print in a line the number of alumni among all the people who come to the celebration. Then in the second line, print the ID of the oldest alumnus – notice that the 7th - 14th digits of the ID gives one’s birth date. If no alumnus comes, output the ID of the oldest guest instead. It is guaranteed that such an alumnus or guest is unique.

Sample Input:

5
372928196906118710
610481197806202213
440684198612150417
13072819571002001X
150702193604190912
6
530125197901260019
150702193604190912
220221196701020034
610481197806202213
440684198612150417
370205198709275042
1
2
3
4
5
6
7
8
9
10
11
12
13

Sample Output:

3
150702193604190912

中文题目

7-5 校庆 (25 分)

2019 年浙江大学将要庆祝成立 122 周年。为了准备校庆,校友会收集了所有校友的身份证号。现在需要请你编写程序,根据来参加校庆的所有人士的身份证号,统计来了多少校友。

输入格式:

输入在第一行给出不超过 10^​5 的正整数 N,随后 N 行,每行给出一位校友的身份证号(18 位由数字和大写字母X组成的字符串)。题目保证身份证号不重复。

随后给出前来参加校庆的所有人士的信息:首先是一个不超过 10​^5 的正整数 M,随后 M 行,每行给出一位人士的身份证号。题目保证身份证号不重复。

输出格式:

首先在第一行输出参加校庆的校友的人数。然后在第二行输出最年长的校友的身份证号 —— 注意身份证第 7-14 位给出的是 yyyymmdd 格式的生日。如果没有校友来,则在第二行输出最年长的来宾的身份证号。题目保证这样的校友或来宾必是唯一的。

输入样例:

537292819690611871061048119780620221344068419861215041713072819571002001X1507021936041909126530125197901260019150702193604190912220221196701020034610481197806202213440684198612150417370205198709275042

输出样例:

3150702193604190912

分析

这道题没用set或者unorder set存校友名录会超时。

满分代码

#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<set>
using namespace std;
int main(){int n,m,cnt=0;cin>>n;getchar();string s,old="20190302",ans;set<string> st;for(int i=0;i<n;i++){getline(cin,s);st.insert(s);}cin>>m;getchar();for(int i=0;i<m;i++){getline(cin,s);set<string>::iterator it;if(st.find(s)!=st.end()){cnt++;}if(s.substr(6,8)<old){old=s.substr(6,8);ans=s;}}cout<<cnt<<endl;cout<<ans;return 0;
}

19年春季第二题 PAT甲级 1157 Anniversary(25 分)相关推荐

  1. 19年冬季第二题 PAT甲级 1166 Summit (25分)

    7-3 Summit (25分) A summit (峰会) is a meeting of heads of state or government. Arranging the rest area ...

  2. 19年冬季第二题 PAT甲级 1165 Block Reversing (25分) 跟1133类似的题目

    题目 Given a singly linked list L. Let us consider every K nodes as a block (if there are less than K ...

  3. 19年秋季第一题 PAT甲级 1161 Forever (20 分) 有点儿意思

    如果喜欢我的文章请点赞让我知道噢 题目 7-1 Forever (20 分) "Forever number" is a positive integer A with K dig ...

  4. 17冬第二题 PAT甲级 1141 Ranking of Institutions (25分) 有点鸡贼

    题目 After each PAT, the PAT Center will announce the ranking of institutions based on their students' ...

  5. PAT 甲级 1157 Anniversary

    1157 Anniversary (25 分) Zhejiang University is about to celebrate her 122th anniversary in 2019. To ...

  6. 18年春季第一题 PAT甲级 1144 The Missing Number (20分) 上限感很重要

    Given N integers, you are supposed to find the smallest positive integer that is NOT in the given li ...

  7. PAT甲级1157 Anniversary

    思路 用两个map存储输出的两部分id,mapp1存储校友的id,mapp2存储出席的id.当输入出席id时,用mapp1.find()函数搜索是否为校友,若是则sum++,并将该id记为1:否则记为 ...

  8. PAT 甲级 A1010 Radix (25 分)

    题目传送门 这个题用二分做,我自己写的二分呢太菜了,只能拿到19分,不放出来丢人了.后面看了yxc的代码,美妙绝伦哈. 慢慢来拜读一下. #include "bits/stdc++.h&qu ...

  9. PAT甲级 1032 Sharing (25分) 测试点5陷阱

    题目 1032 Sharing 分析 suffix是后缀,题目的意思是求两个单词的公共后缀的第一个字符的地址.我看有些博客说求的是首个共用结点的地址,我觉得是不对的. 晴神/柳神的解法,是把第一个单词 ...

最新文章

  1. 10.基于Tomcat的SmartUplaod文件上传
  2. Spring MVC中使用Swagger生成API文档和完整项目示例Demo,swagger-server-api(二十)
  3. linux双屏显示不同内容,LINUX下双屏显示问题
  4. win10 管理linux文件,Linux子系统文件可在未来的Win10发行版中通过资源管理器访问...
  5. Android7.1 Presentation双屏异显原理分析
  6. Dynamics CRM 注册插件dll到GAC
  7. :empty css 可以用在哪些标签,CSS3 :empty 选择器
  8. Maven 私服的简单使用
  9. Mysql实战之高可用HMA
  10. Spark sql数据倾斜优化的一个演示案例
  11. 从csrss弹出的ASSERT对话框谈起
  12. 最大流(Maximum Flow)
  13. 用两个队列实现栈---用两个队列实现栈
  14. 云计算就业前景怎么样 学后可以胜任哪些岗位
  15. 集合竞价如何买入_散户可以在集合竞价时买入股票吗?
  16. Ubuntu 16.04 LTS 完善解决亮度调整
  17. 异构数据库结构与数据同步工具dbswitch
  18. 干货|一文看懂什么是“非标资产”
  19. Win7(老PC)Python环境搭建实战
  20. 如何将pdf转换成jpg图片的格式

热门文章

  1. 计算机知识更新迭代太快,技术更新迭代的步伐越走越快 盘点一年IT圈 几多欢喜几多愁...
  2. 法国大学 语言C1,法国留学的语言要求是什么?
  3. java读取pi_java读取PI数据库测点值
  4. 微信小程序手机扫码上传图片报错500
  5. 解决Error running ‘Tomcat(备注这里你起的名字)‘: SSL HTTP Connector node not found: set up one in the server.xml
  6. gitolite 搭建Android仓库(三)
  7. Java访问数据库的具体步骤:
  8. 【阿里云高校计划】Day4 汽车保险数据查询
  9. 《Ruby》学习笔记
  10. 易趣又来送钱了【分享】