-
Notifications
You must be signed in to change notification settings - Fork 0
/
1039.cpp
48 lines (46 loc) · 1012 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
46
47
48
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
vector<int> stu[26*26*26*10];
int main()
{
freopen("input.in","r",stdin);
freopen("output.out","w",stdout);
int count=0;
int n,k;
scanf("%d%d",&n,&k);
for(int i=0;i<k;i++)
{
int index,nj;
scanf("%d%d",&index,&nj);
for(int j=0;j<nj;j++)
{
char name[5];
scanf("%s",name);
int base=(name[0]-'A')*26*26*10+(name[1]-'A')*26*10+(name[2]-'A')*10+(name[3]-'0');
stu[base].push_back(index);
}
}
for(int i=0;i<n;i++)
{
char name[5];
scanf("%s",name);
int base=(name[0]-'A')*26*26*10+(name[1]-'A')*26*10+(name[2]-'A')*10+(name[3]-'0');
if(stu[base].size()>0)
{
sort(stu[base].begin(),stu[base].end());
printf("%s %d",name,stu[base].size());
for(int j=0;j<stu[base].size();j++)
printf(" %d",stu[base][j]);
printf("\n");
}
else
printf("%s 0\n",name);
}
return 0;
}