結果
| 問題 |
No.927 Second Permutation
|
| コンテスト | |
| ユーザー |
yujirosan
|
| 提出日時 | 2019-11-23 01:02:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 582 bytes |
| コンパイル時間 | 1,773 ms |
| コンパイル使用メモリ | 170,772 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-11 06:40:05 |
| 合計ジャッジ時間 | 2,891 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 WA * 18 |
ソースコード
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
typedef long long ll;
#define rALL(a) (a).rbegin(),(a).rend()
int main(){
string s; cin >> s;
sort(rALL(s));
bool flag = true;
if(s[0]!='0' && s[1]=='0') flag = false;
for(int i=1;i<s.size()-1;i++){
if(s[i]!=s[i+1]){
char tmp=s[i];
s[i] = s[i+1];
s[i+1] = tmp;
break;
}
if(i==s.size()-2) flag = false;
}
if(s[0] == '0') false;
if(flag) cout << s << endl;
else cout << -1 << endl;
return 0;
}
yujirosan