PAT Basic 1072 Opening Message (20 points)

 

The figure is a school of Shanghai new semester Message: day to drop any man also, we must first delete its micro-Bo, unloading its QQ, sealing their computer, and took the phone, to close its ipad, off their wifi, so bored, then, the net surface, barber, Zhengyi, then remorse, reading, exercise, wise, enlightened, sophisticated. Then Cheng Kung University also!

jiyu.JPG

This question asks you to write a program to help school teachers to check items for all students to help their National Cheng Kung University.

Input formats:

Input of the first line gives two positive integers N ( ≤ 1000) and M ( ≤. 6), respectively, the number of students and the number of kinds of items to be confiscated. The second line gives the number M needs to be confiscated the item number, which number is four digits. Then N lines, each line gives the student's initials (1-4 by the English capital letters), the number of personal items K (0  ≤ K  ≤ 10), and the number of K items.

Output formats:

Check each student in turn carry the goods, if there is to be confiscated items, press the following output formats and information that the student needs to be confiscated items (note the end line shall not have extra space):

姓名缩写: 物品编号1 物品编号2 ……

The total number of problems in the last line of output and the total number of students to be confiscated items.

Sample input:

4 2
2333 6666
CYLL 3 1234 2345 3456
U 4 9966 6666 8888 6666
GG 2 2333 7777
JJ 3 0012 6666 2333

Sample output:

U: 6666 6666
GG: 2333
JJ: 6666 2333
3 5
#include <iostream>
#include <vector>

using namespace std;

bool OBJ[1000000]={false};

struct stu{
    string name;
    vector<int> nf;
};

int main()
{
    int M,N,tmp;
    vector<stu> v;
    cin>>M>>N;
    for(int i=0;i<N;i++) {
        cin>>tmp;OBJ[tmp]=true;
    }
    while(M--){
        stu tmp_s;int tmp_sn;
        cin>>tmp_s.name>>tmp_sn;
        while(tmp_sn--){
            int tmp_index;
            cin>>tmp_index;
            if(OBJ[tmp_index]) tmp_s.nf.push_back(tmp_index);
        }
        if(tmp_s.nf.size()!=0) v.push_back(tmp_s);
    }
    int obj_num=0;
    for(int i=0;i<v.size();i++){
        printf("%s:",v[i].name.c_str());
        for(int j=0;j<v[i].nf.size();j++){
            printf(" %04d",v[i].nf[j]);
            obj_num++;
        }
        printf("\n");
    }
    cout<<v.size()<<" "<<obj_num<<endl;
    system("pause");
    return 0;
}

A case you have not seen may be due% 04d, you need four output

Guess you like

Origin www.cnblogs.com/littlepage/p/11700772.html