ZJU PAT 1012 有一个测试点过不去
时间限制
400 ms
内存限制
32000 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue
To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programming Language, M - Mathematics (Calculus or Linear Algrbra), and E - English. At the mean time, we encourage students by emphasizing on their best ranks -- that is, among the four ranks with respect to the three courses and the average grade, we print the best rank for each student.
For example, The grades of C, M, E and A - Average of 4 students are given as the following:
StudentID C M E A
310101 98 85 88 90
310102 70 95 88 84
310103 82 87 94 88
310104 91 91 91 91
Then the best ranks for all the students are No.1 since the 1st one has done the best in C Programming Language, while the 2nd one in Mathematics, the 3rd one in English, and the last one in average.
Input
Each input file contains one test case. Each case starts with a line containing 2 numbers N and M (<=2000), which are the total number of students, and the number of students who would check their ranks, respectively. Then N lines follow, each contains a student ID which is a string of 6 digits, followed by the three integer grades (in the range of [0, 100]) of that student in the order of C, M and E. Then there are M lines, each containing a student ID.
Output
For each of the M students, print in one line the best rank for him/her, and the symbol of the corresponding rank, separated by a space.
The priorities of the ranking methods are ordered as A > C > M > E. Hence if there are two or more ways for a student to obtain the same best rank, output the one with the highest priority.
If a student is not on the grading list, simply output "N/A".
Sample Input
5 6
310101 98 85 88
310102 70 95 88
310103 82 87 94
310104 91 91 91
310105 85 90 90
310101
310102
310103
310104
310105
999999
Sample Output
1 C
1 M
1 E
1 A
3 A
N/A
#include <iostream>
#include <string.h>
using namespace std;
const int MAX=2048;
int N,M;
int acme[MAX][7];
int m[MAX];
//互换
int Achange(int i,int j)
{
int t;
for(int k=0;k<7;++k)
{
t=acme[i][k];
acme[i][k]=acme[j][k];
acme[j][k]=t;
}
return 0;
}
//起泡排序
int Qqsort(int k,int low,int high)
{
if(low>=high)return 0;
int i=low;
while(i<high)
{
if(acme[i+1][k]>acme[i][k])
Achange(i,i+1);
++i;
}
Qqsort(k,low,i-1);
return 0;
}
int main()
{
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
scanf("%d %d",&N,&M);
int i=0,j=0,k=0,h=0;
for(;i<N;++i)
{
float t=0;
scanf("%d %d %d %d",&acme[i][0],&acme[i][3],&acme[i][2],&acme[i][1]);
t=(float)(acme[i][1]+acme[i][2]+acme[i][3])/3;
t+=0.5;
acme[i][4]=(int)t;
}
for(;j<M;++j)
scanf("%d",&m[j]);
Qqsort(4,0,N-1);
for(i=0;i<N;++i)
{
acme[i][5]=4;
if(acme[i][4]==acme[i-1][4]&&i>=1)
acme[i][6]=acme[i-1][6];
else
acme[i][6]=i+1;
}
for(j=3;j>=1;--j)
{
Qqsort(j,0,N-1);
int score=acme[0][j],scoreR=1;
for(i=0;i<N;++i)
{
if(acme[i][j]<score)++scoreR,score=acme[i][j];
if(scoreR<acme[i][6])
{
if(acme[i][j]==score)
acme[i][6]=scoreR;
else
{
acme[i][6]=i+1;
score=acme[i][j],scoreR=i+1;
}
acme[i][5]=j;
}
}
}
///输出
for(i=0;i<M;++i)
{
int ifprint=0;
for(j=0;j<N;++j)
{
if(m[i]==acme[j][0])
{
printf("%d ",acme[j][6]);
if(acme[j][5]==4)printf("A\n");
if(acme[j][5]==3)printf("C\n");
if(acme[j][5]==2)printf("M\n");
if(acme[j][5]==1)printf("E\n");
ifprint=1;
break;
}
}
if(ifprint==0)printf("N/A\n");
}
return 0;
}相关推荐
ZJU PAT Basic Level 乙级1001-1025 代码
浙江大学PAT OJ(pat.zju.edu.cn)乙级(中文)1001-1025 题目AC代码。 本人纯手打,原创。
神经网络自校正PID控制器自适应PID研究(Matlab代码实现)
内容概要:本文系统研究了神经网络自校正PID控制器在自适应控制中的应用,重点通过Matlab代码实现了该控制器的设计与仿真,并将其应用于永磁同步电机(PMSM)等复杂非线性系统的速度控制中。文章详细对比了该方法与传统PID控制、滑模控制的性能差异,验证了其在动态响应精度、鲁棒性及自适应调节能力方面的显著优势。资源包还提供了丰富的Simulink仿真模型,涵盖无位置传感器控制、高频注入法、负载转矩估计、滑模观测器、谐波抑制、弱磁控制等多种先进电机控制策略,构建了一个面向高性能电机驱动的综合算法研究平台。; 适合人群:具备自动控制理论基础和Matlab/Simulink仿真能力的研究生、科研人员,以及从事电机控制、智能控制算法开发的工程技术人员。; 使用场景及目标:①深入掌握神经网络与PID融合的自校正机制及其在非线性系统中的自适应调控原理;②开展PMSM先进控制策略(如无感控制、滑模观测、负载估计)的建模仿真与性能对比分析;③支撑科研项目验证、学术论文复现或毕业课题的技术实现与创新拓展。; 阅读建议:建议结合所提供的Matlab代码与Simulink模型进行动手实践,重点关注控制器结构设计、参数整定过程及仿真结果分析,同时参考配套文献以深化对控制理论和工程应用背景的理解,从而实现从理论到仿真的完整闭环学习与创新能力提升。
usecase.svg
usecase.svg
ESP32物联网开发实战项目 - 温湿度监测上云教程:DHT11采集、WiFi连接、MQTT上报、OLED显示与手机端查看全套源码
从接线到上云一步步做,每步含完整代码、接线表与预期输出,零基础照着做就能让温湿度数据实时显示在手机。 本教程做一个能联网的温湿度监测节点:ESP32 读取 DHT11 温湿度,本地 OLED 屏实时显示,同时通过 WiFi 把数据发到 MQTT 服务器,手机客户端订阅同一主题即可远程看到读数。 采用先拆后合的结构:DHT11 采集、OLED 显示、WiFi 连接、MQTT 上报四个模块各自有独立验证程序和预期串口输出,逐个跑通后再合并为完整监测程序,出错能快速定位到具体模块。
x86 16位微处理器 8086的逻辑结构图
x86 16位微处理器 8086的逻辑结构图


