当前位置:网站首页>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;
}
边栏推荐
- Applicable and inapplicable scenarios of mongodb series
- D check type is pointer
- Jianzhi offer 43.47.46.48 dynamic planning (medium)
- VTK 圆柱体的生成与渲染
- Embedded virlog code running process
- Is it safe to open a securities account? Is there any danger
- PHP非对称加密算法(RSA)加密机制设计
- Common operation and Principle Exploration of stream
- A must for programmers, an artifact utools that can improve your work efficiency n times
- [proteus simulation] Arduino uno key start / stop + PWM speed control DC motor speed
猜你喜欢

Codeforces Global Round 21A~D

Usage of unique function

Build your own PE manually from winpe of ADK

Pycharm远程连接服务器来跑代码

8.Ribbon负载均衡服务调用

Jenkins build prompt error: eacces: permission denied

Freefilesync folder comparison and synchronization software

数学建模经验分享:国赛美赛对比/选题参考/常用技巧

Installation and uninstallation of MySQL software for windows

Comparison of disk partition modes (MBR and GPT)
随机推荐
8.Ribbon负载均衡服务调用
Lucky numbers in the matrix
GC is not used in D
Basic type of typescript
永远不要使用Redis过期监听实现定时任务!
Solutions to the failure of last child and first child styles of wechat applet
团队管理的最关键因素
Sword finger offer 09.30 Stack
Matlab programming related knowledge
Gartner 2022 Top Strategic Technology Trends Report
In insect classes and objects
服务器创建虚拟环境跑代码
Wechat applet - bind and prevent event bubble catch
ArcGIS cannot be opened and displays' because afcore cannot be found ' DLL, solution to 'unable to execute code'
[cqoi2015] task query system
DOS command
微信小程序注册指引
Luogu p4513 xiaobaiguang Park
Obtain information about hard disk and volume or partition (capacity, ID, volume label name, etc.)
Niuke challenge 48 e speed instant forwarding (tree over tree)