Skip to content

Commit f293ccb

Browse files
committed
patB
1 parent 8393524 commit f293ccb

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

DataStructure/patB/B1072.cpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#include <cstdio>
2+
#include <set>
3+
#include <vector>
4+
using namespace std;
5+
6+
int main()
7+
{
8+
int nStu, nItem;
9+
scanf("%d %d", &nStu, &nItem);
10+
set<int> banList;
11+
12+
for(int i = 0; i < nItem; i++)
13+
{
14+
int temp;
15+
scanf("%d", &temp);
16+
banList.insert(temp);
17+
}
18+
19+
int totalStu = 0, totalItem = 0;
20+
for(int i = 0; i < nStu; i++)
21+
{
22+
int flag = 0;
23+
char name[10];
24+
int count;
25+
int item;
26+
vector<int> items;
27+
scanf("%s %d", name, &count);
28+
for(int j = 0; j < count; j++)
29+
{
30+
scanf("%d", &item);
31+
if(banList.find(item) != banList.end())
32+
{
33+
totalItem++;
34+
flag = 1;
35+
items.push_back(item);
36+
}
37+
}
38+
39+
if(flag == 1)
40+
{
41+
totalStu++;
42+
printf("%s:", name);
43+
for(vector<int>::iterator it = items.begin(); it != items.end(); it++)
44+
{
45+
//Please attention to this output format.
46+
printf(" %04d", *it);
47+
}
48+
printf("\n");
49+
}
50+
51+
items.clear();
52+
}
53+
54+
printf("%d %d", totalStu, totalItem);
55+
56+
return 0;
57+
}

0 commit comments

Comments
 (0)