結果

問題 No.927 Second Permutation
ユーザー 0w1
提出日時 2020-01-28 18:19:34
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 397 bytes
コンパイル時間 2,542 ms
コンパイル使用メモリ 195,184 KB
最終ジャッジ日時 2025-01-08 20:41:56
ジャッジサーバーID
(参考情報)
judge2 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
  ios::sync_with_stdio(false);

  string X;
  cin >> X;

  sort(X.begin(), X.end());
  reverse(X.begin(), X.end());

  for (int i = X.size() - 2; ~i; --i) {
    if (X[i + 1] == '0') continue;
    if (X[i] != X[i + 1]) {
      swap(X[i], X[i + 1]);
      cout << X << endl;
      return 0;
    }
  }

  cout << -1 << endl;

  return 0;
}
0