結果
| 問題 |
No.927 Second Permutation
|
| コンテスト | |
| ユーザー |
Rubikun
|
| 提出日時 | 2019-11-22 21:24:26 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 2,000 ms |
| コード長 | 476 bytes |
| コンパイル時間 | 1,927 ms |
| コンパイル使用メモリ | 169,680 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-11 02:47:00 |
| 合計ジャッジ時間 | 2,716 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005,INF=1<<30;
int main(){
string S;cin>>S;
sort(all(S));
reverse(all(S));
bool ok=true;
for(int i=S.size()-1;i>=1;i--){
if(S[i]!=S[i-1]&&(i>=2||S[i]!='0')){
ok=false;
swap(S[i],S[i-1]);
break;
}
}
if(ok) cout<<-1<<endl;
else cout<<S<<endl;
}
Rubikun