题解
2025-08-14 13:27:29
发布于:上海
1阅读
0回复
0点赞
简单的结构体排序
#include<bits/stdc++.h>
typedef long long LL;
#define int LL
#ifdef WIN32
#define getchar _getchar_nolock
#define putchar _putchar_nolock
#else
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
using namespace std;
namespace fastIO
{
inline char get_char()
{
char c=getchar();
while(c<=32) c=getchar();
return c;
}
inline int read()
{
int x=0,f=1;
char c=getchar();
for(;c<'0'||c>'9';c=getchar())if(c=='-') f=-1;
for(;c>='0'&&c<='9';c=getchar()) x=(x<<3)+(x<<1)+c-48;
return x*f;
}
inline void write(int x)
{
if(x<0) putchar('-'),x=-x;
if(x>9) write(x/10);
putchar(x%10+48);
}
inline void file()
{
freopen(".in","r",stdin);
freopen(".out","w",stdout);
}
inline void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
}
using namespace fastIO;
namespace my
{
const int N=1e6+1;
int n;
struct student{
int id,x,y;
}a[N];
inline istream& operator>>(istream& in,student &s)
{
in>>s.id>>s.x>>s.y;
return in;
}
inline ostream& operator<<(ostream& out,student &s)
{
out<<s.id<<endl;
return out;
}
inline bool operator<(student a,student b)
{
if(a.y!=b.y) return a.y>b.y;
if(a.x!=b.x) return a.x>b.x;
return a.id<b.id;
}
int main()
{
fast();
cin>>n;
for(int i=1;i<=n;++i) cin>>a[i];
sort(a+1,a+n+1);
for(int i=1;i<=n;++i) cout<<a[i];
return 0;
}
}
signed main()
{
my::main();
return 0;
}
这里空空如也
有帮助,赞一个