#5#6的相同日期不应该先输入的在前吗?
  • 板块P1104 生日
  • 楼主diannaojun
  • 当前回复0
  • 已保存回复0
  • 发布时间2022/7/27 20:47
  • 上次更新2023/10/27 18:06:49
查看原帖
#5#6的相同日期不应该先输入的在前吗?
576573
diannaojun楼主2022/7/27 20:47

相同日期不应该先输入的在前吗?

关于#5测试点,

  • LeslieLeslie数据为 1991,11,101991,11,10
  • XiebingXiebing数据也是 1991,11,101991,11,10

但是,LeslieLeslie在第4242行输入,XiebingXiebing在第5353输入,所以,不是应该LeslieLeslieXiebingXiebing前输出吗?我曾想:可能要换一下顺序吧。所以就有了#6测试点。


关于#6测试点,

  • LeslieLeslie数据还是 1991,11,101991,11,10
  • XiebingXiebing数据也还是 1991,11,101991,11,10

但是,LeslieLeslie还在第4242行输入,XiebingXiebing也还在第5353输入,掉换完顺序后#5测试点到AC了,但#6测试点WA了。so,各位大牛们,这到底是怎么一般事情?


附上本人的代码(CPP)(码风不是太好)

#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
struct stu{
	string name;
	short year=2021,day=32,month=13;
};
bool comp(stu*a,stu*b){
	if((a->year)!=(b->year))return ((a->year)>(b->year));
	if((a->month)!=(b->month))return ((a->month)>(b->month));
	if((a->day)!=(b->day))return ((a->day)>(b->day));
	return true;
}
void input(stu*s){
	cin>>s->name;
	short a,b,c;
	scanf("%hd%hd%hd",&s->year,&s->month,&s->day);
}
void swap(stu*S,int a,int b){
	stu k=S[a];
	S[a]=S[b],S[b]=k;
}
int main (){
	//freopen("D:\\a.out","w",stdout);
	short N;
	scanf("%hd",&N);
	stu S[N];
	for(short I=0;I<N;I++)input(S+I);
	for(short I=0,K=N-1;I<N;I++){
		for(short J=0;J<K;J++){
			if(comp(S+J,S+J+1))swap(S,J,J+1);
		}
	}
	for(short I=0;I<N;I++)cout<<S[I].name<<endl;
	return 0;
}
2022/7/27 20:47
加载中...