-
Notifications
You must be signed in to change notification settings - Fork 0
/
1039.cpp
45 lines (42 loc) · 877 Bytes
/
1039.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
// main.cpp
// test
//
// Created by 李寻欢 on 2019/10/1.
// Copyright © 2019 李寻欢. All rights reserved.
//
#include <stdio.h>
#include <iostream>
#include <string>
#include <map>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>
#include <unordered_map>
#include <string.h>
#include <set>
using namespace std;
int n,k;
unordered_map<string,set<int>> database;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
string name;
cin >> n >> k;
for(int i=0;i<k;++i){
int a,b;
cin >> a>>b;
for(int j=0;j<b;++j){
cin >> name;
database[name].insert(a);
}
}
for(int i=0;i<n;++i){
cin >> name;
cout << name << " "<<database[name].size();
for(auto each:database[name]) cout << " " << each;
cout <<"\n";
}
}