結果
問題 |
No.927 Second Permutation
|
ユーザー |
|
提出日時 | 2019-11-23 13:33:52 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 454 bytes |
コンパイル時間 | 642 ms |
コンパイル使用メモリ | 119,680 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-30 15:39:41 |
合計ジャッジ時間 | 1,729 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 17 |
ソースコード
#include <stdio.h> #include <algorithm> #include <cstring> #include <utility> constexpr int N = 1e5; char str[N+1]; int main(void){ scanf("%s", str); int n = strlen(str); std::sort(str, str+n); if(str[0] == str[n-1]){puts("-1"); return 0;} for(int i = 1; i < n; ++i) if(str[0] != str[i]){ std::swap(str[0], str[i]); break; } std::reverse(str, str+n); if(str[0] == '0') puts("-1"); else puts(str); return 0; }