当前位置:网站首页>School day (summer vacation daily question 2)
School day (summer vacation daily question 2)
2022-07-25 05:27:00 【sweetheart7-7】
2019 Zhejiang University will celebrate its establishment in 122 Anniversary of the .
In preparation for the school day , Alumni Association collects all alumni ID number. .
Now I need you to write a program , The ID number of all the people who attend the celebration. , Count how many alumni have come .
Input format
The input gives a positive integer on the first line N N N.
And then N N N That's ok , Each row gives an alumni ID number. ( 18 18 18 Bits consist of numbers and uppercase letters X Composed string ). The title ensures that the ID number is not duplicated. .
Then give the information of all the people who came to attend the school celebration :
First is a positive integer M M M.
And then M M M That's ok , Each row gives the ID number of a person. . The title ensures that the ID number is not duplicated. .
Output format
First, output the number of alumni participating in the celebration in the first line .
Then output the oldest alumni ID number in the second row. —— Pay attention to ID No 7 − 14 7−14 7−14 Bit gives yyyymmdd Birthday in format .
If no alumni come , Then output the ID number of the oldest guests in the second row. . The title guarantees that such alumni or guests must be the only one .
Data range
1 ≤ N , M ≤ 1 0 5 1≤N,M≤10^5 1≤N,M≤105
sample input :
5
372928196906118710
610481197806202213
440684198612150417
13072819571002001X
150702193604190912
6
530125197901260019
150702193604190912
220221196701020034
610481197806202213
440684198612150417
370205198709275042
sample output :
3
150702193604190912
#include<iostream>
#include<unordered_set>
using namespace std;
const int N = 100010;
int n, m;
unordered_set<string> S;
int main(){
scanf("%d", &n);
char in_str[20];
for(int i = 0; i < n; i++)
scanf("%s", in_str), S.insert(in_str);
scanf("%d", &m);
int cnt = 0, last = 0;
string res = "", s;
for(int i = 0; i < m; i++){
scanf("%s", in_str);
s = in_str;
int flag = S.count(s);
if(flag) cnt++;
if(res.empty() || flag > last ||
(flag == last && s.substr(6, 8) < res.substr(6, 8))){
res = s;
last = flag;
}
}
printf("%d\n%s", cnt, res.c_str());
return 0;
}
边栏推荐
- rhce第一天
- STL notes (I): knowledge system
- The second day of rhcsa summer vacation
- LCP plug-in creates peer-to-peer physical interface
- 300. Longest increasing subsequence
- 05. Libavformat Library of ffmpeg
- STL notes (III): input / output stream
- How to carry out the function test with simple appearance and complex interior?
- Thesis reading | which is the best multilingual pre training technology for machine translation? See the latest progress!
- 接口幂等性
猜你喜欢

In depth understanding of pre post + +, -- and negative modulus

ThreadLocal

Array programming problem of CSDN programming challenge

Build keyword driven automated testing framework

CSDN编程挑战赛之数组编程问题

Solve the problem that uni app applet obtains routes and route parameters

panda3d 键盘移动场景

Go language function

剑指 Offer 05. 替换空格

编程大杂烩(二)
随机推荐
Typera+picgo+ Alibaba cloud OSS setup and error reporting solution [reprint]
H5 new feature domcontentloaded event - custom attribute -async attribute -history interface method - local storage -postmessage
Sword finger offer II 012. the sum of the left and right subarrays is equal
Event cycle mechanism browser nodejs async await execution sequence promise execution sequence interview questions
The global shipment of glory 8x series exceeded 10million units, and the glory V20 exceeded 1.5 million units!
Add transition layer to JS page
How to carry out the function test with simple appearance and complex interior?
LCP plug-in creates peer VLAN interface
剑指offer专项突击版第9天
background
unity 3D物体添加 点击事件
接口幂等性
What should testers do if they encounter a bug that is difficult to reproduce?
Project management tool - Introduction and practice of Alibaba cloud projex
Implement is by yourself_ class
Guanghetong and Intel released the global version of 5g communication module
epoll的实现原理
VPP不能加载UP状态接口
C编程 --“最大子数组的和” 的动态规划的解法
panda3d 键盘移动场景