結果
| 問題 |
No.927 Second Permutation
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2019-11-22 21:24:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 2,000 ms |
| コード長 | 391 bytes |
| コンパイル時間 | 1,558 ms |
| コンパイル使用メモリ | 170,980 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-11 02:47:16 |
| 合計ジャッジ時間 | 2,682 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000
int main(){
string S;
cin>>S;
sort(S.begin(),S.end(),greater<char>());
//cout<<S<<endl;
if(!prev_permutation(S.begin(),S.end())){
cout<<-1<<endl;
}
else{
if(S[0]=='0')cout<<-1<<endl;
else cout<<S<<endl;
}
return 0;
}
沙耶花