-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathA1039.cpp
43 lines (40 loc) · 820 Bytes
/
A1039.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
#include <cstring>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
const int M = 26*26*26*10 + 1;
vector<int> course[M];
int getID(char name[]){
int id = 0;
for(int i = 0; i < 3; ++i){
id = id * 26 + (name[i] - 'A');
}
id = id*10 + (name[3] - '0');
return id;
}
int main(){
int n, k;
char name[5];
scanf("%d%d", &n, &k);
for(int i = 0; i < k; ++i){
int c, x;
scanf("%d%d", &c, &x);
for(int i = 0; i < x; ++i){
scanf("%s", name);
int id = getID(name);
course[id].push_back(c);
}
}
for(int i = 0; i < n; ++i){
scanf("%s", name);
int id = getID(name);
sort(course[id].begin(), course[id].end());
printf("%s %d", name, course[id].size());
for(int j = 0; j < course[id].size(); ++j){
printf(" %d", course[id][j]);
}
printf("\n");
}
return 0;
}