Language: C

#include <bits/stdc++.h>
using namespace std;

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    i64 N,A,B;
    cin >> N >> A >> B;

    if(N<A+B-1){
        cout << -1 << endl;
        return;
    }
    if(A==N){
        if(B!=1){
            cout << -1 << endl;
            return;
        }
        rep(i,1,N+1){
            cout << i;
            if(i==N) cout << endl;
            else cout << " ";
        }
        return;
    }
    if(B==N){
        if(A!=1){
            cout << -1 << endl;
            return;
        }
        for(int i=N; i>=1; --i){
            cout << i;
            if(i==1) cout << endl;
            else cout << " ";
        }
        return;
    }
    if(B==1){
        if(A!=N){
            cout << -1 << endl;
            return;
        }
        rep(i,1,N+1){
            cout << i;
            if(i==N) cout << endl;
            else cout << " ";
        }
        return;
    }
    if(A==1){
        if(B!=N){
            cout << -1 << endl;
            return;
        }
        for(int i=N; i>=1; --i){
            cout << i;
            if(i==1) cout << endl;
            else cout << " ";
        }
        return;
    }

    if(A*B<N){
        cout << -1 << endl;
        return;
    }

    vector<int> ans(N);
    i64 b=N-B+1,used=0;
    rep(i,0,B){
        ans[N-i-1]=b+i;
        ++used;
    }

    cerr << ans << endl;

    rep(i,0,A+1){
        i64 k=(N-i+B-1)/B;
        print(i);
        print(k);
        if(i+k!=A) continue;
        rep(j,0,k-1){
            i64 c=min(N-used-i,B),used_=used;
            print(c);
            b-=c;
            rep(i2,0,c){
                ans[N-used_-i2-1]=b+i2;
                ++used;
            }
        }
        rep(j,1,i+1) ans[j-1]=j;
        cerr << ans << endl;
        return;
    }

#ifdef TEST
    vector<int> p(N);
    rep(i,1,N+1) p[i-1]=i;
    do{
        vector<int> inc(N+2,inf),dec(N+2);
        inc[0]=0;
        dec[0]=inf;
        rep(i,0,N){
            rep(j,0,N){
                if(inc[j]<p[i]) inc[j+1]=min(inc[j+1],p[i]);
                if(dec[j]>p[i]) dec[j+1]=max(dec[j+1],p[i]);
            }
        }
        if(inc[A]==inf) continue;
        if(inc[A+1]!=inf) continue;
        if(dec[B]==0) continue;
        if(dec[B+1]!=0) continue;
        rep(i,0,N){
            cout << p[i];
            if(i==N-1) cout << endl;
            else cout << " ";
        }
        return;
    }while(next_permutation(begin(p),end(p)));
    cout << -1 << endl;
#endif
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.