結果

問題 No.927 Second Permutation
ユーザー zeronosu77108
提出日時 2020-06-24 21:29:41
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 569 bytes
コンパイル時間 1,441 ms
コンパイル使用メモリ 140,380 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-30 18:45:32
合計ジャッジ時間 2,326 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <climits>
#include <map>
#include <queue>
#include <cmath>

using namespace std;

using int64 = long long;

int main() {
    string s;
    cin >> s;
    string t = s;
    sort(t.rbegin(), t.rend());
    if (all_of(t.begin()+1, t.end(), [](const char& c){return c=='0';})) {
        cout << -1 << endl;
        return 0;
    }
    prev_permutation(t.begin(), t.end());

    if (t == s) {
        cout << "-1" << endl;
    } else {
        cout << t << endl;
    }
}
0