結果

問題 No.927 Second Permutation
ユーザー fura
提出日時 2020-04-13 13:02:50
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 278 bytes
コンパイル時間 3,027 ms
コンパイル使用メモリ 197,904 KB
最終ジャッジ日時 2025-01-09 17:56:30
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	string s; cin>>s;
	sort(s.rbegin(),s.rend());
	if(!prev_permutation(s.begin(),s.end()) || s[0]=='0') puts("-1");
	else{
		for(char c:s) putchar(c);
		puts("");
	}
	return 0;
}
0