結果
問題 |
No.927 Second Permutation
|
ユーザー |
![]() |
提出日時 | 2019-12-06 13:52:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 418 bytes |
コンパイル時間 | 1,657 ms |
コンパイル使用メモリ | 171,424 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-23 05:15:17 |
合計ジャッジ時間 | 3,348 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 17 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);++i) #define all(a) (a).begin(),(a).end() using namespace std; typedef long long ll; int main(){ ios::sync_with_stdio(false); cin.tie(0); string S; cin >> S; int k = S.size(); sort(all(S)); reverse(all(S)); swap(S[k-1],S[k-2]); if(S[k-1] == S[k-2] || S[0] == '0'){ cout << -1 << endl; return 0; } cout << S << endl; return 0; }