結果
問題 | No.927 Second Permutation |
ユーザー |
![]() |
提出日時 | 2019-11-22 22:23:06 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 456 bytes |
コンパイル時間 | 1,396 ms |
コンパイル使用メモリ | 161,488 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-11 04:05:17 |
合計ジャッジ時間 | 2,505 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 10 WA * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { string s,copy; cin>>s; copy=s; int si=s.size(),count=0; sort(s.begin(),s.end()); for(int i=si-1;i>=0;i--){ if(s[i]=='0'){ count++; } } if(si-1==count || copy==s){ cout<<-1<<'\n'; } else{ swap(s[si-1],s[si-2]); for(int i=si-1;i>=0;i--){ cout<<s[i]; } cout<<'\n'; } return 0; }