結果

問題 No.39 桁の数字を入れ替え
コンテスト
ユーザー あるふぁ
提出日時 2026-08-31 21:20:41
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 378 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,238 ms
コンパイル使用メモリ 349,936 KB
実行使用メモリ 9,732 KB
最終ジャッジ日時 2026-08-31 21:20:49
合計ジャッジ時間 3,430 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

int main(){
    string S;
    cin >> S;

    ll ans = (S.size() == 1? stoll(S): -1);
    for (int i = 0; i < S.size(); i++){
        for (int j = i+1; j < S.size(); j++){
            string s = S;
            swap(s[i], s[j]);
            ans = max(ans, stoll(s));
        }
    }

    cout << ans << endl;
}
0