佬,看看我的第二题,卡死9%了 #include<iostream> (30316)#include<string> #include<vector> (30320)#include<algorithm> #include<map> using namespace std; typedef pair<string, int> PAIR; struct cmp{ bool operator()(const PAIR& l, const PAIR& r){ return l.second > r.second; } }; int main(){ int n,q; cin>>n>>q; map<string, int> m; vector<PAIR> vec; for(int i=0;i<q;i++){ string tmp; cin>>tmp; m.insert(PAIR(tmp,i)); } for(int i=0;i<n;i++){ string s1; cin>>s1; int tmp; cin>>tmp; int count=0; for(int k=0;k<tmp;k++){ string s2; cin>>s2; map<string,int>::iterator it = m.find(s2); if(it!=m.end()) count++; } vec.push_back(PAIR(s1, count)); } sort(vec.begin(), vec.end(),cmp()); for(int i=0;i!=vec.size();i++){ cout<<vec[i].first<<endl; } return 0; }
点赞 1

相关推荐

你背过凌晨4点的八股文么:简历挂了的话会是流程终止,像我一样
点赞 评论 收藏
分享
今年读完研的我无房无车无对象,月入还没有过万&nbsp;看到他在朋友圈晒房产证,感叹自己白读了这么多年书
小浪_Coding:学历不代表就能赚多少钱, 自己硕士学历怎么说也是一方面好事, 工作只是为了谋生, 赚钱跟学历不挂钩, 看自己走什么样的路,做什么选择
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务