Language: C++

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <numeric>
#include <string>
#include <complex>
#include <algorithm>
#include <iostream>
#include <vector>
#include <bitset>
#include <deque>
#include <queue>
#include <map>
#include <utility>
#include <functional>
#include <iomanip>
#include <unordered_map>
#include <set>
using namespace std;
using ull = unsigned long long;
using  ll =long long ;
using  prll =pair<ll, ll>;
constexpr ll MOD = 1000000007;           //10億　= 10^9になってる
constexpr ll mINF = -922337200085470000; //llのmax-1桁の小さい方
constexpr ll pINF = 1LL << 60;
constexpr ull uINF=  1844674407399900000; //ullのmax-1桁してる
constexpr long double  pi = 3.1415926535897932384;
constexpr ll juu = 100000;             //10万 10e5
constexpr ll hyaku = 1000000;         //100万　10e6
constexpr int dx[4] = {0,0,1,-1}; //上下左右のベクトル
constexpr int dy[4] = {1,-1,0,0}; //上下左右のベクトル
constexpr int ddx[8] = {0,0,1,-1,1,1,-1,-1};
constexpr int ddy[8] = {1,-1,0,0,-1,1,1,-1};
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Debug(xx) cerr << " DEBUG:"<< xx << endl ;
#define Debug2(xx,yy) cerr << " DEBUG:"<< xx << ":" << yy<< endl ;
ll factor[300];
ll memory[300];
/*素朴法で計算
factorは必ずmemset(factor,0,sizeof(factor));
グローバルであるmemoryに個数を書き込む
memory配列の走査にはfactorの要素を使う*/
void primefac(ll num)
{
    int i = 0, kosuu = 0;
    while (*(factor + i) != 0)
    {
        while (num % *(factor + i) == 0)
        {
            num /= *(factor + i);
            memory[*(factor + i)] += 1;
        }
        if (num == 1)
            break;
        i++;
    }
}
/*グローバルにあるfactorに素数書き込む.個数を返すので配列は-1しろforは<*/
int elast(ll number)
{
    ll tmp = 0;
    int flag = 0;
    *factor = 2;
    for (int i = 3; i <= number; i++)
    {
        flag = 0;
        for (int j = 0; j <= tmp; j++)
        {
            if (i % (*(factor + j)) == 0)
            {
                flag = 1;
                break;
            }
        }
        if (flag)
            continue;
        tmp += 1;
        *(factor + tmp) = i;
    }
    return tmp + 2;
}
//繰り返し二乗。掛けられる数、回数、mod
ll powpow(ll n, ll p)
{
    if (p == 1)
        return n % MOD;
    if (p % 2 == 1)
    {
        return (n * powpow(n, p - 1)) % MOD;
    }
    ll dob = powpow(n, p / 2);
    return (dob * dob) % MOD;
}
//MODとn、rが互いに素である事が確定していないとこれは出来ない。小定理、またchild,parentでおかしくなる。 mod取った後にそれら同士で割り算するとおかしくなるから逆元使う。（合同式の性質考えろ）
ll nCrMod(ll n, ll r)
{
    ll child = 1;
    ll parent = 1;
    if (r == 0)
        return 1;
    for (ll i = 0; i < r; ++i)
    {
        child = child * (n - i) % MOD;
        parent = parent * (r - i) % MOD;
    }
    ll ans = child * powpow(parent, MOD - 2);
    return ans % MOD;
}
ll to_digit(ll num){
    return (ll)(to_string(num).size());
}
ll nCr(ll n, ll r)
{
    ll val = 1,val2 = 1;
    if (r == 0)
        return 1;
    if(n < r)
        return 0;
    for (ll i = 0; i < r; ++i)
    {
        val *= (n - i);
        val2 *= (r - i);
    }
    return val/val2;
}
ll nPr(ll n, ll r)
{
    ll val = 1;
    for (ll i = 0; i < r; ++i)
    {
        val *= (n - i);
    }
    return val;
}
template <typename T>
bool chmin(T &a, const T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
bool chmax(T &a, const T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

/*ソートして被りを無くす*/
template <typename T>
void eraseSame(T &a)
{
    sort(all(a));
    a.erase(unique(all(a)), a.end());
}

/*aとbで大きい方を後ろにする。変更なしならtrue、ありならfalse */
template <typename T>
bool swapmax(T &a, T &b)
{
    T temp;
    temp = a;
    if (a > b)
    {
        a = b;
        b = temp;
        return false;
    }
    return true;
}
ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

/*一行に入力が何個あるかを1,ぶち込むvectorを2*/
template <typename T>
void splitIn(ll N, vector<T> &array)
{
    T temp;
    int i = 0;
    if (N == 0)
    {
        return;
    }
    array.resize(N);
    while (cin >> temp)
    {
        array[i] = temp;
        i++;
        if (i >= N)
        {
            break;
        }
    }
    return;
}
static ll k;
static ll sum;



unordered_map<ll,ll> mp;

void dfs(ll num){
    if(num > 3234566667){
        return;
    }
    mp[num] = num;
    int last = num % 10;
    ++sum;
    if(mp[num] != 0)return mp[num];
    if(sum > k){
        return ;
        }
    if(last == 0){
        dfs(num *10 + 0);
        dfs(num *10 + 1);
    }
    else if(last == 9){
        dfs(num*10 + 8);
        dfs(num*10 + 9);
    }
    else{
        dfs(num * 10 + last-1);
        dfs(num*10 + last);
        dfs(num*10 + last+1 );
    }
    return ;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout << fixed << setprecision(20);
    ll n, m,l;
    ll ans = 0;
    string s;
    sum = 9;
    cin >> k;
    for(int i= 1;i<10;++i)dq.push_back(i);
    if(k < 10){
        cout << k;
        return 0;
    }
    dfs(1LL);
    sort(all(mp));
    auto itr = mp.begin();
    rep(i,k-1)itr++;
    cout << *itr.first;
    return 0;
}

Compiler output:
a.cc: In function 'void dfs(ll)':
a.cc:219:34: error: return-statement with a value, in function returning 'void' [-fpermissive]
  219 |     if(mp[num] != 0)return mp[num];
      |                                  ^
a.cc: In function 'int main()':
a.cc:249:27: error: 'dq' was not declared in this scope; did you mean 'dy'?
  249 |     for(int i= 1;i<10;++i)dq.push_back(i);
      |                           ^~
      |                           dy
a.cc:258:18: error: 'struct std::__detail::_Node_iterator<std::pair<const long long int, long long int>, false, false>' has no member named 'first'
  258 |     cout << *itr.first;
      |                  ^~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:8:
/usr/include/c++/14/bits/stl_algo.h: In instantiation of 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __detail::_Node_iterator<pair<const long long int, long long int>, false, false>; _Compare = __gnu_cxx::__ops::_Iter_less_iter]':
/usr/include/c++/14/bits/stl_algo.h:4772:18:   required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = __detail::_Node_iterator<pair<const long long int, long long int>, false, false>]'
 4772 |       std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter());
      |       ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:255:9:   required from here
  255 |     sort(all(mp));
      |     ~~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1906:50: error: no match for 'operator-' (operand types are 'std::__detail::_Node_iterator<std::pair<const long long int, long long int>, false, false>' and 'std::__detail::_Node_iterator<std::pair<const long long int, long long int>, false, false>')
 1906 |                                 std::__lg(__last - __first) * 2,
      |                                           ~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:67,
                 from /usr/include/c++/14/bits/specfun.h:43,
                 from /usr/include/c++/14/cmath:3906,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  618 |     operator-(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:618:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:1906:50: note:   'std::__detail::_Node_iterator<std::pair<const long long int, long long int>, false, false>' is not derived from 'const std::reverse_iterator<_Iterator>'
 1906 |                                 std::__lg(__last - __first) * 2,
      |                                           ~~~~~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1790 |     operator-(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:1906:50: note:   'std::__detail::_Node_iterator<std::pair<const long long int, long long int>, false, false>' is not derived from 'const std::move_iterator<_IteratorL>'
 1906 |                                 std::__lg(__last - __first) * 2,
      |                                           ~~~~~~~^~~~~~~~~
In file included from a.cc:7:
/usr/include/c++/14/complex:370:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&, const complex<_Tp>&)'
  370 |     operator-(const complex<_Tp>& __x, const complex<_Tp>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/complex:370:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:1906:50: note:   'std::__detail::_Node_iterator<std::pair<const long long int, long long int>, false, false>' is not derived from 'const std::complex<_Tp>'
 1906 |                                 std::__lg(__last - __first) * 2,
      |                                           ~~~~~~~^~~~~~~~~
/usr/include/c++/14/complex:379:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&, const _Tp&)'
  379 |     operator-(const complex<_Tp>& __x, const _Tp& __y)
      |     ^~~~~~~~
/usr/include/c++/14/complex:379:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:1906:50: note:   'std::__detail::_Node_iterator<std::pair<const long long int, long long int>, false, false>' is not derived from 'const std::complex<_Tp>'
 1906 |                                 std::__lg(__last - __first) * 2,
      |                                           ~~~~~~~^~~~~~~~~
/usr/include/c++/14/complex:388:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const _Tp&, const complex<_Tp>&)'
  388 |     operator-(const _Tp& __x, const complex<_Tp>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/complex:388:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:1906:50: note:   'std::__detail::_Node_iterator<std::pair<const long long int, long long int>, false, false>' is not derived from 'const std::complex<_Tp>'
 1906 |                                 std::__lg(__last - __first) * 2,
      |                                           ~~~~~~~^~~~~~~~~
/usr/include/c++/14/complex:465:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&)'
  465 |     operator-(const complex<_Tp>& __x)
      |     ^~~~~~~~
/usr/include/c++/14/complex:465:5: note:   candidate expects 1 argument, 2 provided