結果
| 問題 |
No.927 Second Permutation
|
| コンテスト | |
| ユーザー |
onsen_manjuuu
|
| 提出日時 | 2020-06-17 01:57:05 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 2,000 ms |
| コード長 | 410 bytes |
| コンパイル時間 | 1,572 ms |
| コンパイル使用メモリ | 172,400 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-03 12:03:20 |
| 合計ジャッジ時間 | 3,011 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
string s; cin >> s;
int n = s.size();
string t = s;
if(count(s.begin(), s.end(), '0') == n - 1 || unique(t.begin(), t.end()) == t.begin() + 1) {
cout << -1 << endl;
return 0;
}
sort(s.begin(), s.end(), greater<char>());
prev_permutation(s.begin(), s.end());
cout << s << endl;
}
onsen_manjuuu