求助 !!! memcmp方式,样例和对拍过,提交不过
题目传送门
#include<bits/stdc++.h>
using namespace std;
typedef struct __packed {
int zf,cm,maxcm,xh;
}cj;
int cmp(const void *a, const void *b){
return memcmp(a,b,3*sizeof(int))>0 ? -1:1;
}
int main(){
int n ,c,m,e;
cin>>n;
cj *pcj;
int *pm;
pcj = new cj[n+1];
pm = new int [n+1];
for (int i = 0 ;i< n; i++){
cin >> c>>m>>e;
pcj[i].zf = c + m + e;
pcj[i].cm = c + m;
pcj[i].maxcm = max(c,m);
pcj[i].xh = i;
}
qsort( pcj,n,sizeof(cj),cmp);
int cnt =1;
for (int i =0;i< n;i++){
pm[pcj[i].xh]= cnt;
if (memcmp(&pcj[i],&pcj[i+1],3*sizeof(int))!=0)
cnt =i+2;
}
for (int i =0;i< n;i++)
cout <<pm[i]<<endl;
delete []pcj;
delete []pm;
return 0;
}
帮帮可怜的我把,谢谢^qwq^