pat 1075
来源:互联网 发布:c语言数字字符是什么 编辑:程序博客网 时间:2024/06/06 19:16
1075. PAT Judge (25)
时间限制 200 ms
内存限制 32000 kB
代码长度限制 16000 B
判题程序 Standard 作者 CHEN, Yue
The ranklist of PAT is generated from the status list, which shows the scores of the submittions. This time you are supposed to generate the ranklist for PAT.
Input Specification:
Each input file contains one test case. For each case, the first line contains 3 positive integers, N (<=104), the total number of users, K (<=5), the total number of problems, and M (<=105), the total number of submittions. It is then assumed that the user id's are 5-digit numbers from 00001 to N, and the problem id's are from 1 to K. The next line contains K positive integers p[i] (i=1, ..., K), where p[i] corresponds to the full mark of the i-th problem. Then M lines follow, each gives the information of a submittion in the following format:
user_id problem_id partial_score_obtained
where partial_score_obtained is either -1 if the submittion cannot even pass the compiler, or is an integer in the range [0, p[problem_id]]. All the numbers in a line are separated by a space.
Output Specification:
For each test case, you are supposed to output the ranklist in the following format:
rank user_id total_score s[1] ... s[K]
where rank is calculated according to the total_score, and all the users with the sametotal_score obtain the same rank; and s[i] is the partial score obtained for the i-th problem. If a user has never submitted a solution for a problem, then "-" must be printed at the corresponding position. If a user has submitted several solutions to solve one problem, then the highest score will be counted.
The ranklist must be printed in non-decreasing order of the ranks. For those who have the same rank, users must be sorted in nonincreasing order according to the number of perfectly solved problems. And if there is still a tie, then they must be printed in increasing order of their id's. For those who has never submitted any solution that can pass the compiler, or has never submitted any solution, they must NOT be shown on the ranklist. It is guaranteed that at least one user can be shown on the ranklist.
Sample Input:7 4 2020 25 25 3000002 2 1200007 4 1700005 1 1900007 2 2500005 1 2000002 2 200005 1 1500001 1 1800004 3 2500002 2 2500005 3 2200006 4 -100001 2 1800002 1 2000004 1 1500002 4 1800001 3 400001 4 200005 2 -100004 2 0
Sample Output:1 00002 63 20 25 - 182 00005 42 20 0 22 -2 00007 42 - 25 - 172 00001 42 18 18 4 25 00004 40 15 0 25 -
//这题实在是太坑了
#include <stdio.h>#include <algorithm>using namespace std;int n, k, m;int scores[6];struct Stu{int id;int grade[6]; //记录每道题的分数int perfectNum; //记录完整题目的数目int total; //总分数int vis[6]; //判断是否提交问题j的solutionbool flag; //判断是否该同学一题也没提交或者一题编译也没通过} stu[10010];bool cmp(Stu a, Stu b){if(a.total != b.total)return a.total > b.total;else if(a.perfectNum != b.perfectNum)return a.perfectNum > b.perfectNum;else return a.id < b.id;}int main(){int i, j, id, pro, gra, cnt;while(scanf("%d%d%d", &n, &k, &m) != EOF){for(i = 1; i <= k; i++)scanf("%d", &scores[i]);for(i = 1; i <= n; i++){stu[i].flag = false;stu[i].id = i; //开始没有这句话}for(i = 1; i <= m; i++){scanf("%d%d%d", &id, &pro, &gra);stu[id].id = id; //如果有人不提交任何答案,那么他的id为是0了,这样是不对的stu[id].vis[pro] = 1;if(gra != -1)stu[id].flag = true;if(stu[id].grade[pro] <= gra){if(stu[id].grade[pro] < scores[pro] && gra == scores[pro])stu[id].perfectNum++;stu[id].grade[pro] = gra;}}for(i = 1; i <= n; i++){for(j = 1; j <= k; j++)stu[i].total += stu[i].grade[j];}sort(stu + 1, stu + n + 1, cmp);for(i = 1; i <= n; i++){if(!stu[i].flag) continue;if(i == 1){cnt = i;printf("%d %05d %d", i, stu[i].id, stu[i].total);for(j = 1; j <= k; j++){if(stu[i].vis[j] == 1) printf(" %d", stu[i].grade[j]);else printf(" -");}printf("\n");}else if(stu[i].total == stu[i-1].total){printf("%d %05d %d", cnt, stu[i].id, stu[i].total);for(j = 1; j <= k; j++){if(stu[i].vis[j] == 1) printf(" %d", stu[i].grade[j]);else printf(" -");}printf("\n");}else{printf("%d %05d %d", i, stu[i].id, stu[i].total);cnt = i;for(j = 1; j <= k; j++){if(stu[i].vis[j] == 1) printf(" %d", stu[i].grade[j]);else printf(" -");}printf("\n");}}}return 0;}
The ranklist of PAT is generated from the status list, which shows the scores of the submittions. This time you are supposed to generate the ranklist for PAT.
Input Specification:
Each input file contains one test case. For each case, the first line contains 3 positive integers, N (<=104), the total number of users, K (<=5), the total number of problems, and M (<=105), the total number of submittions. It is then assumed that the user id's are 5-digit numbers from 00001 to N, and the problem id's are from 1 to K. The next line contains K positive integers p[i] (i=1, ..., K), where p[i] corresponds to the full mark of the i-th problem. Then M lines follow, each gives the information of a submittion in the following format:
user_id problem_id partial_score_obtained
where partial_score_obtained is either -1 if the submittion cannot even pass the compiler, or is an integer in the range [0, p[problem_id]]. All the numbers in a line are separated by a space.
Output Specification:
For each test case, you are supposed to output the ranklist in the following format:
rank user_id total_score s[1] ... s[K]
where rank is calculated according to the total_score, and all the users with the sametotal_score obtain the same rank; and s[i] is the partial score obtained for the i-th problem. If a user has never submitted a solution for a problem, then "-" must be printed at the corresponding position. If a user has submitted several solutions to solve one problem, then the highest score will be counted.
The ranklist must be printed in non-decreasing order of the ranks. For those who have the same rank, users must be sorted in nonincreasing order according to the number of perfectly solved problems. And if there is still a tie, then they must be printed in increasing order of their id's. For those who has never submitted any solution that can pass the compiler, or has never submitted any solution, they must NOT be shown on the ranklist. It is guaranteed that at least one user can be shown on the ranklist.
Sample Input:7 4 2020 25 25 3000002 2 1200007 4 1700005 1 1900007 2 2500005 1 2000002 2 200005 1 1500001 1 1800004 3 2500002 2 2500005 3 2200006 4 -100001 2 1800002 1 2000004 1 1500002 4 1800001 3 400001 4 200005 2 -100004 2 0Sample Output:
1 00002 63 20 25 - 182 00005 42 20 0 22 -2 00007 42 - 25 - 172 00001 42 18 18 4 25 00004 40 15 0 25 -
//这题实在是太坑了
#include <stdio.h>#include <algorithm>using namespace std;int n, k, m;int scores[6];struct Stu{int id;int grade[6]; //记录每道题的分数int perfectNum; //记录完整题目的数目int total; //总分数int vis[6]; //判断是否提交问题j的solutionbool flag; //判断是否该同学一题也没提交或者一题编译也没通过} stu[10010];bool cmp(Stu a, Stu b){if(a.total != b.total)return a.total > b.total;else if(a.perfectNum != b.perfectNum)return a.perfectNum > b.perfectNum;else return a.id < b.id;}int main(){int i, j, id, pro, gra, cnt;while(scanf("%d%d%d", &n, &k, &m) != EOF){for(i = 1; i <= k; i++)scanf("%d", &scores[i]);for(i = 1; i <= n; i++){stu[i].flag = false;stu[i].id = i; //开始没有这句话}for(i = 1; i <= m; i++){scanf("%d%d%d", &id, &pro, &gra);stu[id].id = id; //如果有人不提交任何答案,那么他的id为是0了,这样是不对的stu[id].vis[pro] = 1;if(gra != -1)stu[id].flag = true;if(stu[id].grade[pro] <= gra){if(stu[id].grade[pro] < scores[pro] && gra == scores[pro])stu[id].perfectNum++;stu[id].grade[pro] = gra;}}for(i = 1; i <= n; i++){for(j = 1; j <= k; j++)stu[i].total += stu[i].grade[j];}sort(stu + 1, stu + n + 1, cmp);for(i = 1; i <= n; i++){if(!stu[i].flag) continue;if(i == 1){cnt = i;printf("%d %05d %d", i, stu[i].id, stu[i].total);for(j = 1; j <= k; j++){if(stu[i].vis[j] == 1) printf(" %d", stu[i].grade[j]);else printf(" -");}printf("\n");}else if(stu[i].total == stu[i-1].total){printf("%d %05d %d", cnt, stu[i].id, stu[i].total);for(j = 1; j <= k; j++){if(stu[i].vis[j] == 1) printf(" %d", stu[i].grade[j]);else printf(" -");}printf("\n");}else{printf("%d %05d %d", i, stu[i].id, stu[i].total);cnt = i;for(j = 1; j <= k; j++){if(stu[i].vis[j] == 1) printf(" %d", stu[i].grade[j]);else printf(" -");}printf("\n");}}}return 0;}
- PAT 1075 PAT Ranking
- pat 1075 PAT Judge
- PAT 1075
- pat 1075
- pat 1075
- PAT 1075
- Pat(Advanced Level)Practice--1075(PAT Judge)
- PAT(甲级)1075
- 1075 PAT Judge
- 浙大PAT甲级 1075
- PAT甲级1075
- 1075 PAT Judge (25)
- PAT乙级1075
- pat
- 【PAT】
- PAT
- PAT
- PAT
- cocos2d-x利用精灵表和纹理缓存实现优化
- 蓝桥杯 十六进制转八进制十六进制转十进制 十进制转十六进制
- 构造函数不能为虚函数,析构函数要为虚函数
- 技术人员应真正学会的第二课程
- 三和先生原稿 <易經大意>上
- pat 1075
- HashMap、HashTable、LinkedHashMap和TreeMap用法和区别
- Vmware安装red hat linux及VMware tools
- 64位win7安装32位oracle11g r2的一些问题
- 汉澳sinox2013安装详细图解
- 2013.03.16 ie8 不支持str.trim()的写法
- 不容易系列之(3)—— LELE的RPG难题 2045
- 字符串中最长的数字串
- 素数环