pat-a1047. Student List for Course (25)
来源:互联网 发布:linux更改ssh端口号 编辑:程序博客网 时间:2024/05/30 02:52
又是卡时题。。和之前做过一个题反过来而已。。我看时间扩大了一倍以为不卡时用string和map。。超时没话说。。我换了hash后还是超。用的map<int,int>.改成vector<int> record[maxn]过了。。以后也该用vector提高效率
#include<cstdio>#include<algorithm>#include<string>#include<vector>;using namespace std;vector<int> record[26*26*26*11];int main(){int n,m,t,a;char s[10];scanf("%d%d",&n,&m);while(n--){scanf("%s",s);int temp=(s[0]-'A')*26*26*10+(s[1]-'A')*26*10+(s[2]-'A')*10+s[3]-'0';scanf("%d",&t);while(t--){scanf("%d",&a);record[a].push_back(temp);}}for(int i=1;i<=m;++i){sort(record[i].begin(),record[i].end());int len=record[i].size();printf("%d %d\n",i,len);for(int j=0;j<len;++j){int a=record[i][j]/(26*26*10);int b=record[i][j]%(26*26*10)/(26*10);int c=record[i][j]%(26*10)/10;int d=record[i][j]%10;printf("%c%c%c%d\n",a+'A',b+'A',c+'A',d);}}return 0;}
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.
Input Specification:
Each input file contains one test case. For each case, the first line contains 2 numbers: N (<=40000), the total number of students, and K (<=2500), the total number of courses. Then N lines follow, each contains a student's name (3 capital English letters plus a one-digit number), a positive number C (<=20) which is the number of courses that this student has registered, and then followed by C course numbers. For the sake of simplicity, the courses are numbered from 1 to K.
Output Specification:
For each test case, print the student name lists of all the courses in increasing order of the course numbers. For each course, first print in one line the course number and the number of registered students, separated by a space. Then output the students' names in alphabetical order. Each name occupies a line.
Sample Input:10 5ZOE1 2 4 5ANN0 3 5 2 1BOB5 5 3 4 2 1 5JOE4 1 2JAY9 4 1 2 5 4FRA8 3 4 2 5DON2 2 4 5AMY7 1 5KAT3 3 5 4 2LOR6 4 2 4 1 5Sample Output:
1 4ANN0BOB5JAY9LOR62 7ANN0BOB5FRA8JAY9JOE4KAT3LOR63 1BOB54 7BOB5DON2FRA8JAY9KAT3LOR6ZOE15 9AMY7ANN0BOB5DON2FRA8JAY9KAT3LOR6ZOE1
- PAT-A1047. Student List for Course (25)
- pat-a1047. Student List for Course (25)
- PAT A1047. Student List for Course (25)
- PAT A1047 student list for course (25)
- STL--PAT.A1047.Student List for Course
- A1047. Student List for Course (25)
- A1047. Student List for Course
- A1047.Student List for Course
- 1047. Student List for Course (25)-PAT
- 1039. Course List for Student (25)-PAT
- 【PAT】1047. Student List for Course (25)
- PAT 1039. Course List for Student (25)
- PAT 1039. Course List for Student (25)
- PAT 1047. Student List for Course (25)
- PAT 1007 Course List for Student (25)
- PAT 1039. Course List for Student (25)
- PAT 1039. Course List for Student (25)
- PAT 1047. Student List for Course (25)
- android 禁止viewpager预加载
- hrbust 哈理工 统计地雷数量
- Maven慕课网教程笔记
- 杭电ACM(1005)Number Sequence
- poj2993--Emag eht htiw Em Pleh(利用strtok函数)
- pat-a1047. Student List for Course (25)
- Html常用标签
- CharSequence与String的区别
- 奖学金-洛谷 1093
- dedecms织梦 pubdate与senddate区别及定时审核发布插件思路
- CSS继续开车
- (转)根据经纬度计算方位距离
- 洛谷 P1219 八皇后
- jax-ws 创建服务端和客户端