unordered_map全wa求解!
查看原帖
unordered_map全wa求解!
1382224
Iain_楼主2024/12/27 22:09

代码:

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

int main(){
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	int t;
	cin>>t;
	while(t--){
		unordered_map<int,int>mp;
		int n;
		cin>>n;
		for(int i=1;i<=n;i++){
			int x;
			cin>>x;
			mp[i]=x;
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=i-1;j++){
				if(mp[j]==mp[i])mp[j]=0;
			}
		}
		for(int i=1;i<=n;i++){
			if(mp[i]!=0)cout<<mp[i]<<" ";
		}
		cout<<endl;
	}
	return 0;
}

2024/12/27 22:09
加载中...