题解 | #[JLOI2011]不重复数字#

[JLOI2011]不重复数字

https://ac.nowcoder.com/acm/problem/20128

#include <iostream>
#include <unordered_set>
#include <vector>
using namespace  std;
int main()
{
    
    int t;
    cin >> t;
    for(int i=0;i<t;i++)
    {
        unordered_set<int> st;
        vector<int> v;
        int n;
        cin >> n;
        while(n--)
        {
            int x;
            cin >> x;
            if(st.find(x)==st.end())
            {
                v.push_back(x);
                st.insert(x);
            }
        }
        
        for(auto i=v.begin();i!=v.end();i++)
        {
            cout << *i << ' ' ;
        }
        cout << endl;
    }
    return 0;
}
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务