PAT1075. PAT Judge
//终于A了,不难却觉着坑多的的题,注意-1的处理,感觉我是受memset置0的束缚了,可以把初试成绩置-1.就不用debug怎么久,注意对于-1的处理,不然漏洞百出
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
const int maxn=10001;
struct node
{
int id;
int r;
int submitted;
int s[6];
int sub[6];
int perfect;
};
int per[6];
node list[maxn];
vector<node>ans;
bool cmp(node a,node b)
{
if(a.s[0]!=b.s[0])return a.s[0]>b.s[0];
else if(a.perfect!=b.perfect)return a.perfect>b.perfect;
else return a.id<b.id;
}
int main()
{
freopen("input.txt","r",stdin);
int i,j,n,k,m;
memset(per,0,sizeof(per));
memset(list,0,sizeof(list));
while(scanf("%d%d%d",&n,&k,&m)!=EOF)
{
for(i=1;i<=k;i++)scanf("%d",&per[i]);
int uid,pid,s;
for(i=0;i<m;i++)
{
scanf("%d%d%d",&uid,&pid,&s);
list[uid].id=uid;
list[uid].sub[pid]++;
if(s==-1&&list[uid].s[pid]==0) list[uid].s[pid]=-1;
else if(list[uid].s[pid]<s)list[uid].s[pid]=s;
}
for(i=0;i<maxn;i++)
{
for(j=1;j<=k;j++)
{
//if(list[i].s[j]==-1)continue;
if(list[i].s[j]>0)list[i].s[0]+=list[i].s[j];
if(list[i].sub[j]>0&&list[i].s[j]!=-1)list[i].submitted=1;
if(list[i].s[j]==per[j])list[i].perfect++;
}
if(list[i].submitted&&list[i].s[0]>=0)ans.push_back(list[i]);
}
sort(ans.begin(),ans.end(),cmp);
for(i=0;i<ans.size();i++)
{
if(i!=0&&ans[i].s[0]==ans[i-1].s[0])ans[i].r=ans[i-1].r;
else ans[i].r=i+1;
}
for(i=0;i<ans.size();i++)
{
printf("%d %05d %d",ans[i].r,ans[i].id,ans[i].s[0]);
for(j=1;j<=k;j++)
{
if(ans[i].s[j]>0)printf(" %d",ans[i].s[j]);
else if(ans[i].sub[j]>0)printf(" 0");
else printf(" -");
}
printf("\n");
}
}
return 0;
}
PAT1075. PAT Judge的更多相关文章
- PAT1075. PAT Judge (25)
其中在排名输出上参照了 http://blog.csdn.net/xyzchenzd/article/details/27074665,原先自己写的很繁琐,而且还有一个测试点不通过. #include ...
- PAT 1075 PAT Judge[比较]
1075 PAT Judge (25 分) The ranklist of PAT is generated from the status list, which shows the scores ...
- A1075 PAT Judge (25)(25 分)
A1075 PAT Judge (25)(25 分) The ranklist of PAT is generated from the status list, which shows the sc ...
- PTA 10-排序5 PAT Judge (25分)
题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/677 5-15 PAT Judge (25分) The ranklist of PA ...
- PAT 甲级 1075 PAT Judge (25分)(较简单,注意细节)
1075 PAT Judge (25分) The ranklist of PAT is generated from the status list, which shows the scores ...
- PAT_A1075#PAT Judge
Source: PAT A1075 PAT Judge (25 分) Description: The ranklist of PAT is generated from the status lis ...
- PAT Judge
原题连接:https://pta.patest.cn/pta/test/16/exam/4/question/677 题目如下: The ranklist of PAT is generated fr ...
- 10-排序5 PAT Judge
用了冒泡和插入排序 果然没有什么本质区别..都是运行超时 用库函数sort也超时 The ranklist of PAT is generated from the status list, whic ...
- PAT 1075. PAT Judge (25)
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1075 此题主要考察细节的处理,和对于题目要求的正确理解,另外就是相同的总分相同的排名的处理一定 ...
随机推荐
- (C/C++) Interview in English - Threading
Q. What's the process and threads and what's the difference between them? A. A process is an execut ...
- Unable to locate Android SDK used by project
Unable to locate Android SDK used by project: DJIgojava.lang.RuntimeException: Unable to locate Andr ...
- ARM NEON 编程系列2 - 基本指令集
ARM NEON 编程系列2 - 基本指令集 前言 本系列博文用于介绍ARM CPU下NEON指令优化. 博文github地址:github 相关代码github地址:github NEON指令集 主 ...
- NeHe OpenGL教程 第二十一课:线的游戏
转自[翻译]NeHe OpenGL 教程 前言 声明,此 NeHe OpenGL教程系列文章由51博客yarin翻译(2010-08-19),本博客为转载并稍加整理与修改.对NeHe的OpenGL管线 ...
- MYSQL 安装更新,使用,管理,备份和安全等
如何安装更新,使用,管理,备份和安全,维护优化一个MYSQL系统. 一.MYSQL发展历史,特点.对SQL语法进行介绍 二.如何安装一个MYSQL系统 三四.如何利用SQL语言以及其他的客户工具对MY ...
- [Tex学习]给汉字注音
\documentclass{article} \usepackage[CJK]{ruby} \usepackage{pinyin} \begin{document} \begin{CJK*}{GBK ...
- sublime相关设置
1.设置Sublime Text新标签页打开文件 "open_files_in_new_window": false,
- 使用mysql函数 group_concat 一点需要注意的
这个函数是一个非常好用的函数,比如我们可以在 进行多对多关联表,进行批量查询的时候可以用到, 比如学生和老师是多对多的关系,如果我们希望查询 指定的一些老师对应的学生有哪些 的时候,一般的情况,我们可 ...
- maven项目导入eclipse
maven项目的配置文件 web java文件都在src下面 src/main/java src/main/webapp src/main/webapp/web-inf 导入后要重新添加jar包,设置 ...
- 安装LINUX X86-64的10201出现链接ins_ctx.mk错误-转自yingtingkun
详细错误信息为: Error in invoking target ‘install’ of makefile ‘/opt/oracle/product/10.2/ctx/lib/ins_ctx.mk ...