結果
問題 |
No.927 Second Permutation
|
ユーザー |
![]() |
提出日時 | 2019-11-22 21:31:42 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 418 bytes |
コンパイル時間 | 1,607 ms |
コンパイル使用メモリ | 170,192 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-11 02:53:44 |
合計ジャッジ時間 | 2,610 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 WA * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ string s; cin >> s; bool same = true; int n = s.length(); for (int i = 1; i < n; i++) { if (s[i]!= s[i-1]) { same = false; break; } } sort(s.begin(), s.end()); reverse(s.begin(), s.end()); swap(s[n-1], s[n-2]); cout << ((s[0] != '0' && !same) ? s : "-1") << endl; return 0; }