Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
map<int , vector<int> > mp;
for(int i = 1 ; i<=n ; i++){
int x;
cin>>x;
for(int j = 0 ; j<x ; j++){
int type;
cin>>type;
mp[type].push_back(i);
}
}
int q;
cin>>q;
for(int i = 0 ; i<q ; i++){
int x;
cin>>x;
vector<int> v = mp[x];
if(v.size() == 0){
cout<<"None ";
}
else{
set<int> s;
for(int i = 0 ; i<v.size() ; i++){
s.insert(v[i]);
}
for(auto it = s.begin() ; it!=s.end() ; it++){
cout<<*it<<" ";
}
}
cout<<"\n";
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment