結果
| 問題 | No.927 Second Permutation |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-01 20:16:48 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 907 bytes |
| 記録 | |
| コンパイル時間 | 1,698 ms |
| コンパイル使用メモリ | 176,408 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-27 05:31:15 |
| 合計ジャッジ時間 | 3,039 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 WA * 17 |
ソースコード
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
string x;
cin >> x;
map<char,int> mp;
rep(i,x.size()){
mp[x[i]] ++;
}
if(mp.size() == 1){
cout << -1 << endl;
return 0;
}
if(mp.size() == 2 && mp['0'] == x.size() -1){
cout << -1 << endl;
return 0;
}
bool fi = true,se = false ;
char s;
for(auto p:mp){
if(fi){ fi = false;se = true;}
else if(se){s = p.first;break;}
}
mp[s] --;
string ans = "";
ans += s ;
for(auto p:mp){
rep(i,p.second){
ans += p.first ;
}
}
reverse(ans.begin(),ans.end());
cout << ans << endl;
return 0;
}