matter
1.小毛病太多了,真的一时半会儿错了都不知道哪里错了,语法有错,然后代码也要写错,半天根本看不出来问题出在哪里。
2.掌握cmp的标准写法。
code
#include<iostream>
#include<algorithm>
using namespace std;
struct node{
int id , d , c , degree;
}Node[100005];
bool cmp(node a , node b){
if(a.degree == b.degree){
if(a.c + a.d == b.c + b.d){
if(a.d == b.d){
return a.id < b.id;
}
else{
return a.d > b.d;
}
}
else{
return a.d + a.c > b.d + b.c;
}
}
else{
return a.degree < b.degree;
}
}
int main(){
int N , L , H , num = 0;
scanf("%d %d %d" , &N , &L , &H);
for(int i = 0 ; i < N ; i ++){
scanf("%d %d %d" , &Node[i].id , &Node[i].d , &Node[i].c);
//judge the degree
if(Node[i].c >= L && Node[i].d >= L){
num ++;
if(Node[i].d >= H && Node[i].c >= H){
Node[i].degree = 1; // degree 1
}
else if(Node[i].d >= H && Node[i].c < H){
Node[i].degree = 2;// degree 2
}
else if(Node[i].d < H && Node[i].c < H && Node[i].d >= Node[i].c){
Node[i].degree = 3;// degree 3
}
else{
Node[i].degree = 4;// degree 4
}
}
else{
Node[i].degree = 5;
}
}
//get the result
printf("%d\n" , num);
sort(Node , Node + N, cmp);
for(int i = 0 ; i < num ; i ++){
printf("%d %d %d" , Node[i].id , Node[i].d , Node[i].c);
if(i != num - 1) printf("\n");
}
return 0;
}