結果
問題 |
No.927 Second Permutation
|
ユーザー |
![]() |
提出日時 | 2019-11-22 21:52:13 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 512 bytes |
コンパイル時間 | 1,666 ms |
コンパイル使用メモリ | 174,524 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-11 03:23:19 |
合計ジャッジ時間 | 2,704 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ string s; cin >> s; vector<int> a(s.length()); for(int i=0;i<s.length();i++){ a[i]=s[i]-'0'; } sort(a.rbegin(),a.rend()); if(a[s.length()-1]==a[s.length()-2]){ cout << -1 << endl; return 0; } if(s.length()==2 && a[s.length()-1]==0){ cout << -1 << endl; return 0; } swap(a[s.length()-1],a[s.length()-2]); for(int i=0;i<s.length();i++){ cout << a[i]; } }