結果
問題 |
No.927 Second Permutation
|
ユーザー |
![]() |
提出日時 | 2021-07-12 11:05:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 620 bytes |
コンパイル時間 | 1,633 ms |
コンパイル使用メモリ | 170,108 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-02 03:23:39 |
合計ジャッジ時間 | 3,125 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; void no_927(void) { string x; cin >> x; sort(x.begin(), x.end()); reverse(x.begin(), x.end()); int x_size = (int)x.size(); bool is_swap = false; for (int i = x_size - 2; i >= 0; i--) { if (x[x_size - 1] != x[i]) { swap(x[i], x[x_size - 1]); is_swap = true; break; } } if (!is_swap) { cout << "-1" << endl; return; } if (x[0] == '0') { cout << "-1" << endl; return; } cout << x << endl; } int main(void) { no_927(); return 0; }