#include <iostream> #include <map> #include <set> using namespace std; multimap<string,int> mm; int main() { int n;cin>>n; int cnt=0; while(n--){ int x;cin>>x; cnt++; set<string> s; for(int i=1;i<=x;i++){ string st;cin>>st; s.insert(st); } for(auto it:s){ mm.insert({it,cnt}); } } int m;cin>>m; while(m--){ string s;cin>>s; auto range = mm.equal_range(s); for (auto it = range.first; it != range.second; ++it) { cout<<it->second<<' '; } cout<<endl; } } // 64 位输出请用 printf("%lld")
set去重再插入到多重有序映射