結果

問題 No.39 桁の数字を入れ替え
ユーザー wightou
提出日時 2025-07-15 11:58:10
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 688 bytes
コンパイル時間 3,170 ms
コンパイル使用メモリ 278,448 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-07-15 11:58:14
合計ジャッジ時間 4,171 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

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

/////////////////// メイン ///////////////////

int main () {
  
  //////////////////// 入力 ////////////////////

  string n;
  cin >> n;

  //////////////// 出力変数定義 ////////////////

  string result = n;

  //////////////////// 処理 ////////////////////

  int length = n.size();

  for (int i=0; i<length; i++) {
    for (int j=0; j<length; j++) {
      if (i==j) continue;
      swap (n.at(i),n.at(j));
      result = max(result,n);
      swap (n.at(i),n.at(j));
    }
  }

  //////////////////// 出力 ////////////////////

  cout << result << endl;

  //////////////////// 終了 ////////////////////

  return 0;

}
0