結果

問題 No.3629 Maximize Subsequense Mex
コンテスト
ユーザー V_Melville
提出日時 2026-08-14 22:42:01
言語 C++23
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 958 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,994 ms
コンパイル使用メモリ 336,612 KB
実行使用メモリ 9,420 KB
最終ジャッジ日時 2026-08-14 22:42:12
合計ジャッジ時間 6,473 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other WA * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;

void solve() {
    int n;
    cin >> n;
    
    if (n < 10) {
        string s;
        for (int i = 1; i < n; ++i) {
            s += to_string(i);
        }
        s += "0";
        cout << s << '\n';
        return;
    }

    if (n <= 18) {
        int rem = n-10;
        
        string s;
        for (int i = rem; i >= 1; --i) s += to_string(i);
        for (int i = rem+2; i <= 9; ++i) s += to_string(i);
        s += to_string(rem+1);
        rep(i, rem+1) s += to_string(i);
        cout << s << '\n';
        return;
    }

    int m = (n-10)/9;
    int rem = (n-10)%9;

    string s;
    for (int i = rem; i >= 1; --i) {
        s += to_string(i);
    }
    rep(b, m) s += "987654321";

    s += "0123456789";

    cout << s << '\n';
}

int main() {
    int t;
    cin >> t;
    
    while (t--) solve();
    
    return 0;
}
0