60分,求助
查看原帖
60分,求助
129342
love好o楼主2023/9/21 22:02

60分,wa3 wa4,求助,本地可过第3组数据

#include <iostream>
#include <algorithm> 
#include <cstring>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
struct CanDidate{
	int len=0,bh;
	char vote[110];
	bool operator <(const CanDidate &b)const {
		if(len<b.len)return 1;
		else if(len==b.len){
			if(strcmp(vote,b.vote)==-1)return 1;
		}
		return 0;
	}
};
CanDidate sz[21];
int main(int argc, char** argv) {
//	freopen("main.in","r",stdin);
	int n;
	scanf("%d\n",&n);
	char ch;
	for(int i=1;i<=n;i++){
		sz[i].bh=i;
		scanf("%[^\n]\n",&sz[i].vote);
		sz[i].len=strlen(sz[i].vote);
	}
	sort(sz+1,sz+n+1);
	printf("%d\n",sz[n].bh);
	printf("%s",sz[n].vote);
	return 0;
}
2023/9/21 22:02
加载中...