AcWing 4269. 校庆
原题链接
简单
作者:
YAX_AC
,
2024-12-09 19:40:36
,
所有人可见
,
阅读 2
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<unordered_map>
using namespace std;
typedef long long LL;
LL n,m;
int main()
{
unordered_map<string,int> a,b;
vector<string> c,d;
cin>>n;
while(n--)
{
string s;
cin>>s;
a[s] = 1;
}
cin>>m;
while(m--)
{
string ss;
cin>>ss;
d.push_back(ss);
if(a[ss]) c.push_back(ss);
}
cout<<c.size()<<endl;
if(c.size())
{
string t = "99999999";
string maxs;
for(int i = 0; i<c.size(); i++)
{
if(c[i].substr(6,8) < t)
{
t = c[i].substr(6,8);
maxs = c[i];
}
}
cout<<maxs;
}
else
{
string t = "99999999";
string maxs;
for(int i = 0; i<d.size(); i++)
{
if(d[i].substr(6,8) < t)
{
t = d[i].substr(6,8);
maxs = d[i];
}
}
cout<<maxs;
}
return 0;
}