Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) B Box

#include<bits/stdc++.h>
using namespace std;
int shu[100005];
int ans[100005];
int main() {
    int total;
    cin>>total;
    while(total--) {
        int n;
        bool flag=true;
        cin>>n;
        unordered_set < int > Tree;
         SET < int > NUM;
         for ( int I = . 1 ; I <= n-; I ++) num.insert (I); // inserted into each number from small to large 
        for ( int I = . 1 ; I <= n-; I ++) >> CIN Shu [I]; // record each number 
        for ( int I = . 1 ; I <= n-; I ++ ) {
             IF (tree.find (Shu [I]) == Tree. End ()) { // if the current position of the maximum value had not occurred, then the maximum in this position of the first occurrence 
                tree.insert (Shu [I]); // insert
                num.erase (Shu [I]); // delete the 
                ANS [I] = Shu [I]; // record 
            } the else // If the maximum value of the current position occurred, it grew in the maximum number of the pick a useless 
            {
                 for (J = num.begin Auto (); J = num.end ();! J ++ ) {
                     IF ((J *) <Shu [I]) // if 
                     {
                        ANS [I] = (J *); // added to the list 
                        num.erase (J); // delete 
                        BREAK ; // Release circulation 
                    } the else  IF (J *> Shu [I]) { // if the smallest are greater than, 
                        In Flag = to false ;
                         BREAK ;
                    }
                }
                if(!flag) break;
            }
        }
        if(!flag) cout<<-1<<endl;
        else {
            for(int i=1; i<=n; i++) {
                cout<<ans[i]<<" ";
            }
            cout<<endl;
        }

    }
    return 0;
}

 

 

Guess you like

Origin www.cnblogs.com/QingyuYYYYY/p/11964983.html