『1157』Anniversary

news/2025/1/12 1:54:44/

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  . Then N 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  . Then M 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

Sample Output:

3
150702193604190912

Ω

给出校友身份ID,然后统计参加校庆人群中的校友个数,并输出最年长的校友ID。如果没有校友参加,则输出所有宾客中最年长的ID。

最年长ID具有明显的优先级,与pair比较的思想类似,我们可以用pair对 的比较来判断是否需要替换最年长ID。比如说一个校友{false,"19991229"}和一个非校友{true,"18900101"},由于前者的pair较小( ),选择前者为最年长ID。


🐎

#include <iostream>
#include <set>using namespace std;int main()
{set<string> alu;int n, m, cnt = 0;cin >> n;string id, oldest;pair<bool, string> cmp{true, string(8, '9')};for (int i = 0; i < n; ++i)cin >> id, alu.insert(id);cin >> m;bool notAlu;for (int i = 0; i < m; ++i){cin >> id;(notAlu = alu.find(id) == alu.end()) ?: ++cnt;if (make_pair(notAlu, id.substr(6, 8)) < cmp)cmp = make_pair(notAlu, id.substr(6, 8)), oldest = id;}printf("%d\n%s", cnt, oldest.c_str());
}

http://www.ppmy.cn/news/307200.html

相关文章

七、股票是什么?

即使是对股场老手&#xff0c;回顾一下股票的基本知识或许不无益处。 股份的实质很简单&#xff0c;就是一公司之所有权之一部分。股票就是这些所有权的凭证&#xff0c;代表着持股人对该公司的权益&#xff0c;包括公司的资产、负债、收入等等。持有一个公司的股票意味着你是…

Creating cluster [ERR] Node 127.0.0.1:7001 is not configured as a cluster node.

今天在虚拟机中的ubantu中&#xff0c;配置集群&#xff0c;报了这个错。在网上找了半天&#xff0c;才找到个有点关系的。 http://grokbase.com/t/gg/redis-db/15492gz7j4/cluster-setup &#xff0c;大体意思是说配置文件没有配置好。自己只好把6个配置文件来来回回看了好…

2006-京淘Day17

1.JSONP全局异常处理机制 1.1 问题说明 当后端服务器执行出错时,会执行全局异常的处理.但是JSONP的请求的调用要求 返回值类型 callback(JSON)结构.所以需要重构全局异常处理的返回值结构类型. 1.2 编辑全局异常处理机制 package com.jt.aop;import com.fasterxml.jackson…

七喜控股:股价仅相当于3800点水平

新浪提示&#xff1a;本文属于个股点评栏目&#xff0c;仅为证券咨询人士对一只股票的个人观点和分析&#xff0c;并非正式的新闻报道&#xff0c;新浪不保证其真实性&#xff0c;一切有关该股的有效信息&#xff0c;以沪深交易所的公告为准&#xff0c;敬请投资者注意风险。 银…

用一瓶七喜,雅居乐唤醒一座城市的青春狂想

小时候爱喝五花八门的汽水&#xff0c;长大了只敢喝白开水。当二十几岁就在对“老去”这件事唉声叹气&#xff0c;却在突然收到街头“小鲜肉”送来的七喜汽水时欣喜不已&#xff0c;瞬间明白原来自己也还年轻…… 趁青春更向上 七喜风暴席卷昆明广场 9月17日&#xff0c; 昆明…

KEITHLE吉时利7001半机架开关控制主机

吉时利7001是一个半机架尺寸的高密度开关控制器&#xff0c;在工业测试测量方面支持最宽范围的信号接入。DC开关能力从纳伏到1100伏&#xff0c;从飞安(10-15A&#xff09;到5安&#xff0c;再加上RF和光开关能力&#xff0c;使吉时利7001成为应用广泛的测量工具。可以不接计算…

88道Java学习笔记题,百事可乐,万事芬达,心情雪碧,一周七喜,加油!

这篇文章主要介绍了88道经典Java题及答案解析&#xff0c;文中通过示例代码介绍的非常详细&#xff0c;对大家的学习或者面试复习具有一定的参考学习价值&#xff0c;内容过多可以先收藏慢慢观看&#xff0c;需要的朋友们下面随着小编来一起学习学习吧。 另外各位观众老爷觉得内…

7001—Manjaro随笔

一、安装 1—报错&#xff1a;A start job is running for livemedia mhwd scripe 进入安装界面&#xff0c;找到boot&#xff0c;按e进入编辑模式&#xff0c;出现如下界面&#xff1a; 在 driverfree 后面添加 acpi_osi! acpi_osi"Windows2009" 按F10进入boot&…