【2025 年 3 月月赛赛题 A 题解】点名 - chenyuan3's Forum

2025-05-13 16:18:00                  青山依旧在,几度夕阳红。

洛谷原题链接 || Hydro 域原题链接

思路:

类似 2 月月赛赛题 B,只需要按照学号排序然后输出即可。

std by @Genshin_ht:

#include <bits/stdc++.h>

using namespace std;

struct edge{
	int num;
	string name;
}e[1000000];
bool cmp(const edge &a, const  edge &b){
	return a.num < b.num;
}
int main() {
	int n;
	cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> e[i].num >> e[i].name;
	} 
	sort(e + 1, e + n + 1, cmp);
	for(int i = 1;i <= n;i++){
		cout << e[i].name << endl;
	}
}

check by @chenyuan3

#include <bits/stdc++.h>
using namespace std;
int n, x;
string a[50], y;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> x >> y;
		a[x] = y;
	}
	for (int i = 1; i <= n; i++)
	{
		cout << a[i] << endl;
	}
	return 0;
}

本站的所有相关事务,最终解释权归 @chenyuan3 所有。

鱼 #6
鱼「鱼 #6」的图像
鱼 #7
鱼「鱼 #7」的图像
21 天 后

© Copyright 2025 chenyuan3, Some rights reserved.

Powered by: FreeFlarum.
(remove this footer)