結果
問題 |
No.927 Second Permutation
|
ユーザー |
![]() |
提出日時 | 2020-08-03 00:30:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 571 bytes |
コンパイル時間 | 1,807 ms |
コンパイル使用メモリ | 172,212 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-20 01:16:36 |
合計ジャッジ時間 | 3,352 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 11 WA * 16 |
ソースコード
#include <bits/stdc++.h> #define PI 3.14159265359 #define NIL -1 using namespace std; const int64_t MOD = 1e9 + 7; int main() { string X; cin >> X; string S = X; sort(S.begin(), S.end()); string R = S; reverse(R.begin(), R.end()); if (S.at(0) == S.at(S.size() - 1)) { cout << -1 << endl; return 0; } bool b = false; for (int i = 0; i < R.size()-1; i++) { if (R.at(i) != R.at(i + 1)) { char ch = R.at(i); R.at(i) = R.at(i + 1); R.at(i + 1) = ch; b = true; break; } } if (R.at(0) == '0') b = false; cout << (b ? R : "-1") << endl; }