1 solutions

  • 0
    @ 2022-1-17 18:16:09

    看谢老师的博客,set相关的一般用到的都有,注意下就写得出来

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    const int N =1e6+5;
    int main()
    {
    	set<int>q;
    	int n;
    	cin>>n;
    	for(int i=0;i<n;i++)
    	{
    		int a;
    		cin>>a;
    		q.insert(a);
    	}
    	cout<<q.size()<<endl;
    	while(!q.empty())
    	{
    		cout<<*q.begin()<<" ";
    		q.erase(*q.begin());
    	}
    	return 0;
    }
    

    Information

    ID
    1101
    Time
    1000ms
    Memory
    16MiB
    Difficulty
    1
    Tags
    # Submissions
    47
    Accepted
    36
    Uploaded By