文章

1

粉丝

191

获赞

0

访问

217

头像
成绩排序2.0 题解:
P1159 清华大学上机题
发布于2024年3月9日 21:38
阅读数 217

#include<iostream>
#include<set>
using namespace std;

struct compare {
    bool operator()(const pair<int, int>& a, const pair<int, int>& b)const
    {
        if (a.second == b.second)
            return a.first < b.first;
        else
            return a.second < b.second;
    }
};

int main()
{
    int n;
    cin >> n;
    set<pair<int, int>, compare> myset;
    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        myset.insert(make_pair(a, b));
    }
    for (auto& a : myset)
    {
        cout << a.first << " " << a.second << end...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发