結果
問題 | No.927 Second Permutation |
ユーザー |
|
提出日時 | 2020-01-28 18:20:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 2,000 ms |
コード長 | 409 bytes |
コンパイル時間 | 2,692 ms |
コンパイル使用メモリ | 196,896 KB |
最終ジャッジ日時 | 2025-01-08 20:42:06 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#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] != X[i + 1]) {if (i == 0 && X[i + 1] == '0') continue;swap(X[i], X[i + 1]);cout << X << endl;return 0;}}cout << -1 << endl;return 0;}