提出 #11530898


ソースコード 拡げる

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
//using namespace __gnu_pbds;
//typedef tree< pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
//ordered_set;
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
#define X first
#define Y second
#define int long long int 
const int N = (int)1e6 + 10;
const int MOD = 1000000007;


void solve(){
    int k; cin >> k;
    vector<string> a(k + 100);
    for(int i = 1; i <= 9; ++i){
        string n = to_string(i);
        a[i] = n;
    }
    int id = 10;
    int from = 1;
    while(id <= k ){
        int lastch = a[from][a[from].size() - 1] - '0';
        int mn = max(lastch - 1,(int)0);
        int mnm = lastch;
        int mnu = min((int)9, lastch + 1);
        if( lastch == 0 ){
            a[id++] = a[from] + (char)(mnm + '0');
            a[id++] = a[from] + (char)(mnu + '0');
        } else if( lastch == 9){
            a[id++] = a[from] + (char)(mn + '0');
            a[id++] = a[from] + (char)(mnm + '0');
        } else {
            a[id++] = a[from] + (char)(mn + '0');
            a[id++] = a[from] + (char)(mnm + '0');
            a[id++] = a[from] + (char)(mnu + '0');
        }
      	if(id > k) break;
        from++;
    }
    cout << a[k] << '\n';


}   

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
    //int t; cin >> t;
    //while(t--)
        solve();
    return 0;
}

提出情報

提出日時
問題 D - Lunlun Number
ユーザ ritik_patel05
言語 C++14 (GCC 5.4.1)
得点 400
コード長 1639 Byte
結果 AC
実行時間 16 ms
メモリ 6912 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 4
AC × 27
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
etc_01.txt AC 1 ms 256 KiB
etc_02.txt AC 1 ms 256 KiB
etc_03.txt AC 1 ms 256 KiB
etc_04.txt AC 1 ms 256 KiB
etc_05.txt AC 1 ms 256 KiB
etc_06.txt AC 1 ms 256 KiB
etc_07.txt AC 1 ms 256 KiB
etc_08.txt AC 1 ms 256 KiB
etc_09.txt AC 1 ms 256 KiB
etc_10.txt AC 1 ms 256 KiB
etc_11.txt AC 2 ms 384 KiB
etc_12.txt AC 2 ms 384 KiB
etc_13.txt AC 2 ms 512 KiB
etc_14.txt AC 2 ms 384 KiB
etc_15.txt AC 4 ms 1280 KiB
etc_16.txt AC 4 ms 1280 KiB
etc_17.txt AC 6 ms 2176 KiB
etc_18.txt AC 5 ms 1792 KiB
rand_01.txt AC 15 ms 6528 KiB
rand_02.txt AC 15 ms 6272 KiB
rand_03.txt AC 16 ms 6784 KiB
rand_04.txt AC 15 ms 6528 KiB
rand_05.txt AC 16 ms 6656 KiB
sample_01.txt AC 1 ms 256 KiB
sample_02.txt AC 1 ms 256 KiB
sample_03.txt AC 1 ms 256 KiB
sample_04.txt AC 16 ms 6912 KiB