結果
問題 |
No.927 Second Permutation
|
ユーザー |
|
提出日時 | 2020-06-24 21:32:20 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 574 bytes |
コンパイル時間 | 1,134 ms |
コンパイル使用メモリ | 140,164 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-30 18:45:55 |
合計ジャッジ時間 | 2,179 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#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';}) || all_of(t.begin(), t.end(), [&](const char& c){return c==t.front();})) { cout << -1 << endl; return 0; } prev_permutation(t.begin(), t.end()); cout << t << endl; }