请问各位最后两个为何是WA!!
查看原帖
请问各位最后两个为何是WA!!
740313
pukaijun20101021楼主2023/7/7 22:20
#include<bits/stdc++.h>
using namespace std;
struct node{
	string s;
	int y;
	int m;
	int d;
	int cs;
}b[105];
bool cmp(node a,node b){
	if(a.y<b.y){
		return 1;
	}
	if(a.y>b.y){
		return 0;
	}
	if(a.y==b.y){
		if(a.m<b.m){
			return 1;
		}
		if(a.m>b.m){
			return 0;
		}
		if(a.m==b.m){
			if(a.d<b.d){
				return 1;
			}
			if(a.d>b.d){
				return 0;
			}
			if(a.d==b.d){
				if(a.cs<b.cs){
					return 1;
				}
				if(a.cs>b.cs){
					return 0;
				}
			}
		}
	}
}
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>b[i].s>>b[i].y>>b[i].m>>b[i].d;
		b[i].cs=i;
	}
	sort(b+1,b+1+n,cmp);
	for(int i=1;i<=n;i++){
		cout<<b[i].s<<endl;
	}
	return 0;
}
2023/7/7 22:20
加载中...