結果
問題 |
No.927 Second Permutation
|
ユーザー |
![]() |
提出日時 | 2020-04-03 18:57:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 465 bytes |
コンパイル時間 | 1,639 ms |
コンパイル使用メモリ | 171,276 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-03 01:08:04 |
合計ジャッジ時間 | 2,881 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { string s; cin >> s; sort(s.begin(), s.end()); int mi = s[0]; int pos = -1; for (int i = 1; i < s.size(); ++i) { if (s[i] != mi) { pos = i; break; } } if (pos == -1) { puts("-1"); return 0; } swap(s[0], s[pos]); reverse(s.begin(), s.end()); if (s[0] == '0') { puts("-1"); } else { cout << s << '\n'; } return 0; }