社区讨论

30分RE求助

P11185奖牌排序参与者 1已保存回复 1

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
1 条
当前快照
1 份
快照标识符
@m275215f
此快照首次捕获于
2024/10/13 13:22
去年
此快照最后确认于
2024/10/13 13:24
去年
查看原帖
CPP
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
ull n,m,A[2000000],B[2000000],C[2000000];
ull maxa,maxb,maxc,s1[2000000],s2[2000000],s3[2000000];
struct student
{
	ull a,b,c;
}s[200001];
bool cmp(int x,int y)
{
	return x>y;
}
int main()
{
	freopen("2.in","r",stdin);
	//freopen("2.out","w",stdout);
	cin>>n;
	for(ull i=0;i<n;i++)
	{
		cin>>s[i].a>>s[i].b>>s[i].c;
		s1[i]=s[i].a;
		s2[i]=s[i].b;
		s3[i]=s[i].c;
		if(s[i].a>maxa) maxa=s[i].a;
		if(s[i].b>maxb) maxb=s[i].b;
		if(s[i].c>maxc) maxc=s[i].c;
	}
	
	sort(s1,s1+n,cmp);
	sort(s2,s2+n,cmp);
	sort(s3,s3+n,cmp);
	
	cout<<endl; 
	for(ull j=n-1;j>=0;j--) cout<<s1[j]<<endl;
	cout<<endl;
	
	for(ull j=0;j<n;j++)
	{
		if(A[s1[j]]==0)
		{
			A[s1[j]]=j+1;
			//cout<<"A["<<s1[j].a<<"]="<<A[s1[j].a]<<endl;
		}
		if(B[s2[j]]==0)
		{
			B[s2[j]]=j+1;
			//cout<<"B["<<s2[j].b<<"]="<<B[s2[j].b]<<endl;
		}
		if(C[s3[j]]==0)
		{
			C[s3[j]]=j+1;
			//cout<<"C["<<s3[j].c<<"]="<<C[s3[j].c]<<endl;
		}
	}
	for(ull i=0;i<n;i++)
	{
		cout<<min(A[s[i].a],min(B[s[i].b],C[s[i].c]))<<endl;
	}
	return 0;
}

回复

1 条回复,欢迎继续交流。

正在加载回复...