我的个人网站 Cheese的个人主页http://www.cheese.ren/
博客来源 PAT 乙级 1072 开学寄语-Cheese的个人博客PAT 乙级 1072 开学寄语http://blog.cheese.ren/92
欢迎交换友链 :-)
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, goods[6], student_count=0, goods_count=0;
for (int i=0; i<6; i++) {
goods[i] = -1;
}
cin >> n >> m;
for (int i=0; i<m; i++) {
cin >> goods[i];
}
for (int i=0; i<n; i++) {
string name;
int num;
bool flag=true;
cin >> name >> num;
for (int l=0; l<num; l++) {
int id;
cin >> id;
for (int j=0; j<m; j++) {
if (id == goods[j]) {
if (flag) {
flag = false;
student_count++;
cout << name << ":";
}
cout << " ";
cout << setfill('0') << setw(4) << goods[j];
goods_count++;
}
}
}
if (!flag) {
cout << endl;
}
}
cout << student_count << " " << goods_count << endl;
return 0;
}