一直过不了,不知道哪里错了
改好了再改
欢迎指正
#include <iostream>
#include <math.h>
#include <unordered_map>
using namespace std;
string s,c;
int ans;
string mx(string x,string y) {
int a=0,b=0;
for(int i=6; i<14; i++) {
a=10*a+x[i]-'0';
b=10*b+y[i]-'0';
}
return a>b?y:x;
}
int main() {
int n,m;
unordered_map<string,bool> hash;
string str;
cin >> n;
while(n--) {
cin >> str;
if(s.size()==0) s=str;
hash[str]=true;
}
cin >> m;
while(m--) {
cin >> str;
if(c.size()==0) c=str;
if(hash[str]) {
ans++;
s=mx(s,str);
} else {
c=mx(c,str);
}
}
if(ans) cout << ans << endl << s;
else cout << ans << endl << c ;
return 0;
}