結果
問題 | No.927 Second Permutation |
ユーザー |
|
提出日時 | 2019-11-23 00:10:31 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 2,000 ms |
コード長 | 529 bytes |
コンパイル時間 | 1,389 ms |
コンパイル使用メモリ | 95,316 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-11 06:34:23 |
合計ジャッジ時間 | 2,147 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#include<iostream>#include<algorithm>#include<cmath>#include<iomanip>#include<set>#include<map>#include<queue>#include<vector>using namespace std;typedef long long ll;const int MOD=1e9+7;int main() {cin.tie(0),cout.tie(0);ios::sync_with_stdio(false);string s;cin >> s;sort(s.begin(),s.end());reverse(s.begin(),s.end());if(prev_permutation(s.begin(),s.end())) {if(s[0]=='0') {cout << -1 << endl;}else {cout << s << endl;}}else {cout << -1 << endl;}}