結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	string x;
	cin >> x;
	sort(x.begin(),x.end());
	reverse(x.begin(),x.end());
	if(x[1]=='0'){
		cout << -1 << endl;
	}else{
		for(int i=x.size()-1; i>0; i--){
			if(x[i]!=x[i-1]){
				swap(x[i],x[i-1]);
				cout << x << endl; return 0;
			}
		}
		cout << -1 << endl;
	}
	return 0;
}
0