跳到正文

个人记录

CF637B

Mr_Gay约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟

版本

  1. v1当前

题目描述:有一个队列。插入单词,如单词已在队列中,把单词移到队首,否则把单词放到队首。输出队列。

AC Code:

C++
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N=200010;
map<string,bool>m;
string s[N];ll n;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>s[i];
	for(int i=n;i>=1;i--){
		if(m[s[i]])continue;
		cout<<s[i]<<'\n';
		m[s[i]]=true;
	}
}
原文