Submission #11518213


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#ifndef ONLINE_JUDGE
#define deb(x) cout<<#x<<" : "<<x<<"\n";
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\n";
#define deb_arr(a,n) {cout<<#a<<":";for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';}
#define deb_mat(dist,n,m) {cout<<#dist<<"\n";for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}}
#else
#define deb(x) ;
#define debug(x,y) ;
#define deb_arr(a,n) ;
#define deb_mat(dist,n,m) ;
#endif
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define all(a) (a).begin(),(a).end()
#define bs binary_search
#define sz size()
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define clr fflush(stdout);
//#define clr cout.flush();
#define N 200001
#define fpr(i,a,b) for(int i=a;i<b;i++)
#define fdr(i,a,b) for(int i=a;i>b;i--)
#define repp(i,a,b,d) for(int i=a;i<b;i+=d)
#define repd(i,a,b,d) for(int i=a;i>b;i-=d)
#define LLMIN LLONG_MIN
#define LLMAX LLONG_MAX
#define AKASH_PATEL ios_base::sync_with_stdio(false);
#define SVNIT_SURAT cin.tie(NULL);cout.tie(NULL);
#define mset(x,a) memset(x,a,sizeof(x));
#define nl cout<<'\n';
#define print(c) cout<<c<<'\n';
#define setp(n) cout << fixed << setprecision(n)
#define take_arr(a,n) fpr(i,0,n) cin>>a[i];
#define print_arr(a,n) for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';
#define take_mat(mat,n,m) fpr(i,0,n) fpr(j,0,m) cin>>mat[i][j];
#define set_mat(mat,n,m,k) fpr(i,0,n) fpr(j,0,m) mat[i][j]=k;
#define print_mat(dist,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}
template< class T > bool inside(T a, T b, T c) { return a<=b && b<=c; }
template< class T > bool odd(T a) { return a&1; }
template< class T > bool even(T a) { return !(a&1); }
int main()
{
//#ifndef ONLINE_JUDGE
//    freopen("../ip.txt", "r", stdin);
//    freopen("../op.txt", "w", stdout);
//#endif
    AKASH_PATEL;
    SVNIT_SURAT;
    int t=1;
//    cin>>t;
    queue <ll> q;
    fpr(i,1,10)
    {
        q.push(i);
    }
    ll cnt=0;
    vector <ll> v;
    while (!q.empty() && cnt<100000)
    {
        ll tp=q.front();
        q.pop();
        v.pb(tp);
        string s=to_string(tp);
        int x=s.back()-'0';
        if(x-1>=0)
        {
            q.push(stoll(s+char((x-1)+'0'), nullptr,10));
        }
        if(x>=0)
        {
            q.push(stoll(s+char((x)+'0'), nullptr,10));
        }
        if(x+1<=9)
        {
            q.push(stoll(s+char((x+1)+'0'), nullptr,10));
        }
        cnt++;
    }
//    print_arr(v,30)
    while(t--)
    {
        ll n;
        cin>>n;
        cout<<v[n-1]<<'\n';
    }
    return 0;
}



Submission Info

Submission Time
Task D - Lunlun Number
User akashpatel20
Language C++14 (GCC 5.4.1)
Score 400
Code Size 2878 Byte
Status AC
Exec Time 74 ms
Memory 2676 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 27
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All etc_01.txt, etc_02.txt, etc_03.txt, etc_04.txt, etc_05.txt, etc_06.txt, etc_07.txt, etc_08.txt, etc_09.txt, etc_10.txt, etc_11.txt, etc_12.txt, etc_13.txt, etc_14.txt, etc_15.txt, etc_16.txt, etc_17.txt, etc_18.txt, rand_01.txt, rand_02.txt, rand_03.txt, rand_04.txt, rand_05.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Case Name Status Exec Time Memory
etc_01.txt AC 61 ms 2548 KiB
etc_02.txt AC 74 ms 2548 KiB
etc_03.txt AC 63 ms 2676 KiB
etc_04.txt AC 60 ms 2548 KiB
etc_05.txt AC 61 ms 2676 KiB
etc_06.txt AC 63 ms 2548 KiB
etc_07.txt AC 61 ms 2676 KiB
etc_08.txt AC 60 ms 2548 KiB
etc_09.txt AC 59 ms 2548 KiB
etc_10.txt AC 60 ms 2676 KiB
etc_11.txt AC 62 ms 2548 KiB
etc_12.txt AC 59 ms 2548 KiB
etc_13.txt AC 59 ms 2548 KiB
etc_14.txt AC 61 ms 2548 KiB
etc_15.txt AC 59 ms 2548 KiB
etc_16.txt AC 60 ms 2548 KiB
etc_17.txt AC 59 ms 2548 KiB
etc_18.txt AC 61 ms 2676 KiB
rand_01.txt AC 60 ms 2548 KiB
rand_02.txt AC 65 ms 2548 KiB
rand_03.txt AC 61 ms 2676 KiB
rand_04.txt AC 61 ms 2548 KiB
rand_05.txt AC 60 ms 2548 KiB
sample_01.txt AC 62 ms 2676 KiB
sample_02.txt AC 61 ms 2676 KiB
sample_03.txt AC 60 ms 2676 KiB
sample_04.txt AC 59 ms 2676 KiB