一道简单的字符串题
注意特殊情况
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cctype>
#include <unordered_map>
#include <map>
using namespace std;
const int N = 105;
typedef pair<int, string> PII;
int main() {
//先统计出场的人 然后去哈希表中查出现的人
unordered_map<string, bool> mp;
string oldalumni="99999999", oldguest="99999999";
string olda, oldg;
int num = 0;
int n;
cin>>n;
string str, tmp, t;
for(int i = 0; i < n; i++){
cin>>str;
mp[str]= true;
}
int m;
cin>>m;
for(int i = 0; i < m; i++){
cin>>str;
t = str.substr(6, 8);
if(mp[str]){
if(t < oldalumni){
oldalumni = t;
olda = str;
}
num++;
}
if(t < oldguest){
oldguest = t;
oldg = str;
}
}
cout<<num<<endl;
if(num == 0) cout<<oldg<<endl;
else cout<<olda<<endl;
return 0;
}