結果

問題 No.39 桁の数字を入れ替え
ユーザー legosuke
提出日時 2017-12-06 22:03:20
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 327 bytes
コンパイル時間 1,499 ms
コンパイル使用メモリ 159,860 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-29 01:22:05
合計ジャッジ時間 2,365 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main(void) {
  string s;
  cin >> s;

  int p = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] < s[p]) continue;
    p = i;
  }
  
  for (int i = 0; i < p; i++) {
    if (s[i] >= s[p]) continue;
    swap(s[i], s[p]);
    break;
  }
  cout << s << endl;

  return 0;
}
0