当前位置:网站首页>1075 pat judge (25 points)
1075 pat judge (25 points)
2022-06-26 14:14:00 【Destroy it! Goo Hoo!】
All the pits have been tried , I still haven't found anything wrong , alas …
//
// Created by 22385 on 2022/1/24.
//
/* The last test point failed : All scores submitted by a person are 0, You should also output , At this time, it is sorted according to the total score , Those that have not been submitted may rank first Sort by output flag first Still failed !!!!! Student's id Do you need to initialize ?... */
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int maxn=5;
struct record{
char id[10];
int test_num;
int test_score;
}records[100005];
struct student{
char id[10];
int total_score=0;
int test_score[5]={
-2,-2,-2,-2,-2};//-2 Indicates that no
int AC=0;//AC Number of topics
int flag=0;// Identify whether the candidate has submitted through compilation
int rank=0;// ranking
}stu[1005];
// Take the best result of each question
bool cmp1(record a, record b){
if(strcmp(a.id,b.id)!=0) return strcmp(a.id,b.id)<0;
else if(a.test_num!=b.test_num) return a.test_num<b.test_num;
else return a.test_score>b.test_score;
}
bool cmp2(student a, student b){
if(a.flag!=b.flag) return a.flag>b.flag;
else if(a.total_score!=b.total_score) return a.total_score>b.total_score;
else if(a.AC!=b.AC) return a.AC>b.AC;
else return strcmp(a.id,b.id)<0;
}
int main(){
int n, total_test_num, sub_num;
scanf("%d %d %d", &n, &total_test_num, &sub_num);
int value[maxn];
for(int i=0;i<total_test_num;i++){
scanf("%d", &value[i]);
}
for(int i=0;i<sub_num;i++){
scanf("%s %d %d",records[i].id,&records[i].test_num,&records[i].test_score);
}
sort(records,records + sub_num,cmp1);
strcpy(stu[0].id,records[0].id);
// Multiple submissions of the same topic are the highest
int test_num;
for(int i=0,j=0,k;i<sub_num;i++){
if(strcmp(records[i].id,stu[j].id)!=0){
// Next candidate
strcpy(stu[++j].id,records[i].id);
}
test_num = records[i].test_num;
if(stu[j].test_score[test_num-1]==-2){
if(records[i].test_score!=-1){
stu[j].flag=1;
stu[j].test_score[test_num-1]=records[i].test_score;
stu[j].total_score +=stu[j].test_score[test_num-1];
if(stu[j].test_score[test_num-1]==value[test_num-1]) stu[j].AC++;
}else{
stu[j].test_score[test_num-1]=0;
}
}
}
sort(stu,stu+n,cmp2);
int isHave = 1;
for(int i=0;i<n;i++){
if(stu[i].flag==0){
if(i==0) isHave=0;
break;
}else{
if(i!=0 && stu[i].total_score==stu[i-1].total_score){
stu[i].rank=stu[i-1].rank;
}else{
stu[i].rank=i+1;
}
printf("%d %s %d",stu[i].rank,stu[i].id,stu[i].total_score);
for(int j=0;j<total_test_num;j++){
if(stu[i].test_score[j]==-2) printf(" -");
else printf(" %d",stu[i].test_score[j]);
}
printf("\n");
}
}
return 0;
}
边栏推荐
猜你喜欢
2021-10-09
How to convert data in cell cell into data in matrix
Hard (magnetic) disk (I)
Stream常用操作以及原理探索
Postman自动化接口测试
Wechat applet -picker component is repackaged and the disabled attribute is added -- below
Calculate the distance between two points (2D, 3D)
Jenkins build prompt error: eacces: permission denied
Logical operation
Variable declaration of typescript
随机推荐
Is expression of D
Sword finger offer 05.58 Ⅱ string
Memory considerations under bug memory management
8.Ribbon负载均衡服务调用
How to call self written functions in MATLAB
Relevant knowledge of information entropy
虫子 类和对象 中
PHP非对称加密算法(RSA)加密机制设计
Comparison of disk partition modes (MBR and GPT)
ICML 2022 | LIMO: 一种快速生成靶向分子的新方法
免费的机器学习数据集网站(6300+数据集)
On insect classes and objects
使用 Performance 看看浏览器在做什么
Cloudcompare - Poisson reconstruction
Codeforces Global Round 21A~D
Installation and uninstallation of MySQL software for windows
虫子 类和对象 上
C language ---getchar() and putchar()
CF676C Vasya and String
[sdoi2013] forest