PAT 1047. Student List for Course (25)
2015-03-16 08:30
176 查看
//1047. Student List for Course (25) //受不了cin和cout了,一用就超时了,。。。。。。。。。。 //accept #include <iostream> #include <algorithm> #include <vector> using namespace std; //typedef struct //{ // int stu[40005]; // int total; //}Course; int cal(char c[5]) { int tmp; tmp = (c[0] - 'A') * 26*26*26 + (c[1] - 'A')*26*26 + (c[2] - 'A')*26 + c[3] - '0'; return tmp; } void Print(int t) { char i1, i2, i3; int i4; i4 = t %26; t = t / 26; i3 = t%26 + 'A'; t = t/26; i2 = t %26+'A'; t = t/26; i1 = t%26+'A'; printf("%c%c%c%d", i1, i2, i3, i4); //cout << i1<< i2<<i3<<i4; } vector<int> c[2505]; int main() { int N, K; cin >> N >> K; int i; char tmp1[5]; int tmp2; int tmp3; int j; for (i = 0;i<N;i++) { //cin >> tmp1; scanf("%s", &tmp1); int num = cal(tmp1); scanf("%d", &tmp2); for (j = 0;j<tmp2;j++) { scanf("%d", &tmp3); c[tmp3].push_back(num); } } for (i = 1;i<=K;i++) { sort(c[i].begin(), c[i].end()); } for (i = 1;i<=K;i++) { //cout << i << " " << c[i].size() << endl; printf("%d %d\n", i, c[i].size()); for (j = 0;j<c[i].size();j++) { Print(c[i][j]); printf("\n"); //cout << endl; } } return 0; }
相关文章推荐
- 【c++】PAT (Advanced Level) 1007. Maximum Subsequence Sum (25)*
- PAT甲级 1002. A+B for Polynomials (25)
- 【c++】PAT (Advanced Level)1009. Product of Polynomials (25)
- PAT (Advanced Level) 1036. Boys vs Girls (25)
- PAT - 甲级 - 1039. Course List for Student (25)(STL-vecotr)
- 1025 PAT Ranking (25)
- 【PAT】1009. Product of Polynomials (25)
- PAT TEST甲级1007. Maximum Subsequence Sum (25)
- PAT 1020. Tree Traversals (25)
- PAT 数据结构 07-排序2. Insert or Merge (25)
- 1085. PAT单位排行 (25)+2018_3_24
- PAT (Advanced Level) 1056. Mice and Rice (25)
- PAT - 甲级 - 1075. PAT Judge (25)(排序)
- PAT:1082. Read Number in Chinese (25)
- PAT(甲级)1062. Talent and Virtue (25)
- 【PAT】1013. Battle Over Cities (25)
- PAT (Advanced Level) 1003. Emergency (25) 最短路径 DFS
- pat 1048. Find Coins (25)
- PAT 1051. Pop Sequence (25)
- PAT (Basic Level) Practise (中文)1025. 反转链表 (25)C语言