CF637B Chat Order

本题不难,用 map 模拟即可。注意要倒序模拟,代码:

#include <bits/stdc++.h>
using namespace std;

const int N = 2e5 + 5;
map<string, bool> mp;
string s[N];

int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> s[i];
	for (int i = n; i >= 1; i--)
	{
		if (mp[s[i]]) continue;
		cout << s[i] << endl;
		mp[s[i]] = true;
	}
	return 0;
}
posted @ 2022-01-11 11:05  HappyBobb  阅读(9)  评论(0)    收藏  举报  来源