1 solutions

  • 0
    @ 2025-3-3 16:29:40

    C++ :

    #include <iostream>
    #include <vector>
    #include <algorithm>
    using namespace std;
    int N;
    int T;
    int main()
    {
    
        cin>>T;
        while(T--){
            cin>>N;
            vector<int> per;
            vector<int>::iterator it;
            int id;
            for(int i=0;i<N;i++){
                cin >> id;
                it = find(per.begin(),per.end(),id);
                if(it != per.end())
                {
                    per.erase(it);
                }
                per.push_back(id);
            }
            for(int i=per.size()-1;i>=0;i--){
                if(i==0)
                    cout<<per[i];
                else
                    cout<<per[i]<<' ';
            }
            cout<<endl;
        }
        return 0;
    }
    
    • 1

    Information

    ID
    10276
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By