话说,我提供的题,提交怎么还不对呢?
  • 板块灌水区
  • 楼主Alystkia
  • 当前回复25
  • 已保存回复25
  • 发布时间2023/3/25 21:16
  • 上次更新2023/10/23 20:29:53
查看原帖
话说,我提供的题,提交怎么还不对呢?
894838
Alystkia楼主2023/3/25 21:16

可多的考试

此题的题目是我提供的,样例是我的这位朋友写的 @ISU152_YYDS

#include<bits/stdc++.h>
using namespace std;
struct node{
	__int128 id;
	__int128 temp,ch,ma;
}a[300005];
inline __int128 read(){
	__int128 x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		ch=getchar();
		if(ch=='-')f=-1;
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar(); 
	}
	return x*f;
}
bool cmp(node a,node b){
	if(a.ch+a.ma==b.ch+b.ma){
		if(a.ch==b.ch){
			return a.temp<b.temp;
		}
		return a.ch>b.ch;
	}
	return a.ch+a.ma>b.ch+b.ma;
}
inline void print(__int128 x){
	if(x<0){
		putchar('-');
		x=-x;
	}
	if(x>9){
		print(x/10);
	}
	putchar(x%10+'0');
}
signed main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		a[i].temp=read();
		a[i].ch=read();
		a[i].ma=read();
		a[i].id=i;
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=5;i++){
		print(a[i].id);
		cout<<" ";
		print(a[i].temp);
		cout<<" ";
		print(a[i].ch+a[i].ma);
		cout<<endl;
	}
	return 0;
}//你说我咋这么坏呢?嘿嘿嘿。

这是他的解(有很多我都看不懂),都AC了。

#include<bits/stdc++.h>
using namespace std;
#define long long int
struct stu
{
	int id,yu,shu;
}s[10010];
bool cmp(stu a,stu b)
{
	if(a.yu+a.shu>b.yu+b.shu)
		return true;
	else if(a.yu+a.shu==b.yu+b.shu&&a.yu>b.yu)
		return true;
	else if(a.yu+a.shu==b.yu+b.shu&&a.yu==b.yu&&a.id<b.id)
		return true;
	else
		return false;
}
signed main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>s[i].id>>s[i].yu>>s[i].shu;
    sort(s+1,s+n+1,cmp);
    for(int i=1;i<=5;i++)
    {
    	cout<<s[i].id<<" "<<s[i].id<<" "<<s[i].yu+s[i].shu<<endl;
    }
    return 0;
}

这是我的答案,样例过了,可提交全错。

此题本是我一个小测验里的一道题,当时我不会(太弱了)。于是便把题复制下来,请那位朋友帮我一下。 他告诉我用结构体,但是当时我还不知道什么是结构体。现在我又重新做了一遍,样例过了,可提交全错,请球大神知道一下。

我读书少,你可别笑我太弱。

2023/3/25 21:16
加载中...