Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <set>
#include <map>
#include <unordered_map>
#include <vector>
#include <queue>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <random>
#include <chrono>
#include <bitset>
#include <fstream>
#include <sstream>

using namespace std;
using namespace std::chrono;

/*
#define trav(a, v) for(auto& a : v)
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(int i = a; i < (b); ++i)
*/

typedef long long ll;
typedef long double ld;

ll big = 1000000007ll;
ll n,m,k,r;
ll nt;
ll T;

vector<ll> A;
vector<ll> ind;

ll ANS[1000000] = {0};

queue Q2;

bool comp(ll i, ll j){
return A[i] < A[j];
}

int main()
{

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll c1,c2,c3,c4,c5,c6;
    ll a,b,c,d,e;

    cin >> n;
    bool fail = 0;
    for(c1 = 0; c1 < n; c1++){
        cin >> a;
        a--;
        A.push_back(a);
        ind.push_back(c1);
        if(ANS[a] != 0)fail = 1;
        ANS[a] = c1+1;
    }
    
    
    for(c1 = 1; c1 < n; c1++){
        
        for(c2 = 0; c2 < n-c1; c2++){
            Q2.push(c1);
        }
        
    }
    
    queue<ll> Q;

    for(c1 = n*n; c1 >= 0; c1--){

        if(ANS[c1] != 0){
            for(c2 = 0; c2 < ANS[c1] - 1; c2++){
                Q.push(ANS[c1]);
            }
        }
        else{

            if(Q.empty()){
                ANS[c1] = Q2.front();
                Q2.pop();
            }
            else{
                ANS[c1] = Q.front();
                Q.pop();
            }

        }

    }

    if(!Q.empty()){
        fail = 1;
    }

    if(fail == 1){
        cout << "No\n";
    }
    else{
        cout << "Yes\n";
        for(c1 = 0; c1 < n*n; c1++){
            cout << ANS[c1] << " ";
        }
    }


    return 0;
}


Compiler output:
a.cc:42:7: error: class template argument deduction failed:
   42 | queue Q2;
      |       ^~
a.cc:42:7: error: no matching function for call to 'queue()'
In file included from /usr/include/c++/14/queue:66,
                 from a.cc:9:
/usr/include/c++/14/bits/stl_queue.h:195:9: note: candidate: 'template<class _Tp, class _Sequence, class _Alloc, class _Requires> queue(std::queue<_Tp, _Seq>&&, const _Alloc&)-> std::queue<_Tp, _Sequence>'
  195 |         queue(queue&& __q, const _Alloc& __a)
      |         ^~~~~
/usr/include/c++/14/bits/stl_queue.h:195:9: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:191:9: note: candidate: 'template<class _Tp, class _Sequence, class _Alloc, class _Requires> queue(const std::queue<_Tp, _Seq>&, const _Alloc&)-> std::queue<_Tp, _Sequence>'
  191 |         queue(const queue& __q, const _Alloc& __a)
      |         ^~~~~
/usr/include/c++/14/bits/stl_queue.h:191:9: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:187:9: note: candidate: 'template<class _Tp, class _Sequence, class _Alloc, class _Requires> queue(_Sequence&&, const _Alloc&)-> std::queue<_Tp, _Sequence>'
  187 |         queue(_Sequence&& __c, const _Alloc& __a)
      |         ^~~~~
/usr/include/c++/14/bits/stl_queue.h:187:9: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:183:9: note: candidate: 'template<class _Tp, class _Sequence, class _Alloc, class _Requires> queue(const _Sequence&, const _Alloc&)-> std::queue<_Tp, _Sequence>'
  183 |         queue(const _Sequence& __c, const _Alloc& __a)
      |         ^~~~~
/usr/include/c++/14/bits/stl_queue.h:183:9: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:179:9: note: candidate: 'template<class _Tp, class _Sequence, class _Alloc, class _Requires> queue(const _Alloc&)-> std::queue<_Tp, _Sequence>'
  179 |         queue(const _Alloc& __a)
      |         ^~~~~
/usr/include/c++/14/bits/stl_queue.h:179:9: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_queue.h:174:7: note: candidate: 'template<class _Tp, class _Sequence> queue(_Sequence&&)-> std::queue<_Tp, _Sequence>'
  174 |       queue(_Sequence&& __c)
      |       ^~~~~
/usr/include/c++/14/bits/stl_queue.h:174:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_queue.h:170:7: note: candidate: 'template<class _Tp, class _Sequence> queue(const _Sequence&)-> std::queue<_Tp, _Sequence>'
  170 |       queue(const _Sequence& __c)
      |       ^~~~~
/usr/include/c++/14/bits/stl_queue.h:170:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_queue.h:166:9: note: candidate: 'template<class _Tp, class _Sequence, class _Seq, class _Requires> queue()-> std::queue<_Tp, _Sequence>'
  166 |         queue()
      |         ^~~~~
/usr/include/c++/14/bits/stl_queue.h:166:9: note:   template argument deduction/substitution failed:
a.cc:42:7: note:   couldn't deduce template parameter '_Tp'
   42 | queue Q2;
      |       ^~
/usr/include/c++/14/bits/stl_queue.h:96:11: note: candidate: 'template<class _Tp, class _Sequence> queue(std::queue<_Tp, _Sequence>)-> std::queue<_Tp, _Sequence>'
   96 |     class queue
      |           ^~~~~
/usr/include/c++/14/bits/stl_queue.h:96:11: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_queue.h:344:5: note: candidate: 'template<class _Container, class _Allocator, class> std::queue(_Container, _Allocator)-> queue<typename _Container::value_type, _Container>'
  344 |     queue(_Container, _Allocator)
      |     ^~~~~
/usr/include/c++/14/bits/stl_queue.h:344:5: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:340:5: note: candidate: 'template<class _Container, class> std::queue(_Container)-> queue<typename _Container::value_type, _Container>'
  340 |     queue(_Container) -> queue<typename _Container::value_type, _Container>;
      |     ^~~~~
/usr/include/c++/14/bits/stl_queue.h:340:5: note:   candidate expects 1 argument, 0 provided