60pts,能过对拍,求调
查看原帖
60pts,能过对拍,求调
409221
竺子昂楼主2024/11/22 18:05

WA:#1,#3,#4,#5

code:

#include<bits/stdc++.h>
using namespace std;
struct node{
	char name[44];
	string id;
	int score,level;
	int nid=0,srsx;
	//name:名字  id:身份  score:帮贡  level:等级
	//nid:按帮贡排序后的职位  srsx:输入顺序 
};
int n,hf=1,zl=1,tz=1,jy=1;
node a[150];
bool cmp(node x,node y)
{
	if(x.score>y.score) return true;
	if(x.score<y.score) return false;
	return x.level>y.level;
}//按帮贡排序 
bool cmp2(node x,node y)
{
	if(x.nid>y.nid) return true;
	if(x.nid<y.nid) return false;
	if(x.level>y.level) return true;
	if(x.level<y.level) return false;
	return x.srsx<y.srsx;
}//按职位,等级,输入顺序排序 
int main()
{
//	freopen("data.txt","r",stdin);
//	freopen("code.txt","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i].name>>a[i].id>>a[i].score>>a[i].level;
		a[i].srsx=i;
	}
	if(n==3)
	{
		for(int i=1;i<=n;i++)
		{
			cout<<a[i].name<<" "<<a[i].id<<" "<<a[i].level;
		}
		return 0;
	}
	sort(a+4,a+n+1,cmp);
	for(int i=1;i<=3;i++)
	{
		cout<<a[i].name<<" "<<a[i].id<<" "<<a[i].level<<endl;
	}
	for(int i=4;i<=n;i++)
	{
		if(hf<=2)
		{
			hf++;
			a[i].id="HuFa";
			a[i].nid=5;
		}
		else if(zl<=4)
		{
			zl++;
			a[i].id="ZhangLao";
			a[i].nid=4;
		}
		else if(tz<=7)
		{
			tz++;
			a[i].id="TangZhu";
			a[i].nid=3;
		}
		else if(jy<=25)
		{
			jy++;
			a[i].id="JingYing";
			a[i].nid=2;
		}
		else a[i].id="BangZhong";
	}
	sort(a+4,a+n+1,cmp2);
	for(int i=4;i<=n;i++)
	{
		cout<<a[i].name<<" "<<a[i].id<<" "<<a[i].level<<endl;
	}
	return 0;
}

附上对拍数据(难道是数据太弱了?)

#include<bits/stdc++.h>
using namespace std;
int main()
{
	freopen("data.txt","w",stdout);
	srand(time(0));
	int n=rand();
	n=n%11+55;
	cout<<n<<endl;
	int id=114514;
	cout<<"DrangonflyKang BangZhu 100000 66"<<endl;
	cout<<"RenZaiJiangHu FuBangZhu 80000 60"<<endl;
	cout<<"absi2011 FuBangZhu 90000 60"<<endl;
	for(int i=4;i<=n;i++)
	{
		int x=rand()%10000,y=rand()%100;
		cout<<id<<" "<<id<<" "<<x<<" "<<y<<endl;
		id++;
	}
	return 0;
} 
2024/11/22 18:05
加载中...