結果
問題 | No.927 Second Permutation |
ユーザー |
|
提出日時 | 2024-03-27 20:43:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 2,000 ms |
コード長 | 360 bytes |
コンパイル時間 | 4,287 ms |
コンパイル使用メモリ | 254,164 KB |
最終ジャッジ日時 | 2025-02-20 14:06:00 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using ll = long long; using ld = long double; string X; int main() { cin >> X; sort(X.rbegin(), X.rend()); bool flag = prev_permutation(X.begin(), X.end()); if (flag && X[0] == '0') cout << -1 << endl; else cout << (flag ? X: "-1") << endl; return 0; }