-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1039.cpp
More file actions
38 lines (38 loc) · 747 Bytes
/
1039.cpp
File metadata and controls
38 lines (38 loc) · 747 Bytes
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
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int gedit(char *name){
int id = 0;
for(int i=0;i<3;i++){
id = 26*id +(name[i]-'A');
}
id = id*10 + (name[3] - '0');
return id;
}
const int maxn = 26*26*26*10+10;
vector<int> v[maxn];
int main(){
int n, k, no, num, id =0;
char name[5];
scanf("%d%d", &n, &k);
for(int i=0;i<k;i++){
scanf("%d%d",&no, &num);
for(int j=0;j<num;j++){
scanf("%s", name);
id = gedit(name);
v[id].push_back(no);
}
}
for(int i=0;i<n;i++){
scanf("%s", name);
id = gedit(name);
sort(v[id].begin(), v[id].end());
printf("%s %lu", name, v[id].size());
for(int j=0;j<v[id].size();j++)
printf(" %d", v[id][j]);
printf("\n");
}
system("pause");
return 0;
}