結果
| 問題 | No.927 Second Permutation |
| コンテスト | |
| ユーザー |
Rubikun
|
| 提出日時 | 2019-11-22 21:23:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 553 bytes |
| コンパイル時間 | 1,699 ms |
| コンパイル使用メモリ | 171,408 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-11 02:46:06 |
| 合計ジャッジ時間 | 2,825 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 22 WA * 5 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005,INF=1<<30;
int main(){
//std::ifstream in("text.txt");
//std::cin.rdbuf(in.rdbuf());
string S;cin>>S;
sort(all(S));
reverse(all(S));
bool ok=true;
for(int i=S.size()-1;i>=1;i--){
if(S[i]!=S[i-1]&&(i>=2||S[i]!=0)){
ok=false;
swap(S[i],S[i-1]);
break;
}
}
if(ok) cout<<-1<<endl;
else cout<<S<<endl;
}
Rubikun