結果
問題 |
No.927 Second Permutation
|
ユーザー |
![]() |
提出日時 | 2019-11-22 21:27:19 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 655 bytes |
コンパイル時間 | 2,283 ms |
コンパイル使用メモリ | 198,864 KB |
最終ジャッジ日時 | 2025-01-08 04:35:53 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 17 |
ソースコード
#include<bits/stdc++.h> using namespace std; using Int = long long; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} struct FastIO{ FastIO(){ cin.tie(0); ios::sync_with_stdio(0); } }fastio_beet; template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);} //INSERT ABOVE HERE signed main(){ string s; cin>>s; string t; Int zs=0; for(char c:s){ if(c=='0') zs++; else t+=c; } sort(t.rbegin(),t.rend()); if(!prev_permutation(t.begin(),t.end())) drop(-1); cout<<t<<string(zs,'0')<<endl; return 0; }