# PAT 解题报告 1047. Student List for Course (25)

### 1047. Student List for Course 题目描述：

Zhejiang University has 40000 students and provides 2500 courses. Now given the registered course list of each student, you are supposed to output the student name lists of all the courses.

### 1047. Student List for Course 算法分析：

```#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> course[2501];

int main()
{
int n,k;
char name[10];
int nc, c;
int hashv;
scanf("%d %d", &n, &k);

for(int i=0;i<n;i++)
{
scanf("%s %d", name, &nc);
hashv = (name[0]<<24) + (name[1]<<16) + (name[2]<<8) + name[3];
for(int j=0;j<nc;j++)
{
scanf("%d", &c);
course1.push_back(hashv);
}
}
for(int i=1;i<=k;i++)
{
printf("%d %d\n", i, course[i].size());
sort(course[i].begin(), course[i].end());
for(int j=0;j<course[i].size();j++) {
hashv = course[i][j];
printf("%c%c%c%c\n",
(hashv & 0xff000000) >> 24,
(hashv &   0xff0000) >> 16,
(hashv &     0xff00) >> 8,
hashv & 0xff);
}
}
return 0;
}
```

### 1047. Student List for Course 注意点：

Written on January 19, 2014