結果

問題 No.39 桁の数字を入れ替え
ユーザー weaken
提出日時 2020-10-11 14:54:40
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 473 bytes
コンパイル時間 2,494 ms
コンパイル使用メモリ 194,492 KB
最終ジャッジ日時 2025-01-15 06:37:50
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
using namespace std;

int main() {
  fastIO;

  string src;
  cin >> src;

  int ans = stoi(src);
  for (size_t i = 0; i < src.size() - 1; ++i) {
    for (size_t j = i + 1; j < src.size(); ++j) {
      string copy = src;

      char temp = copy[i];
      copy[i] = copy[j];
      copy[j] = temp;
      ans = max(ans, stoi(copy));
    }
  }

  cout << ans << '\n';
  return 0;
}
0