結果
問題 | No.927 Second Permutation |
ユーザー |
|
提出日時 | 2021-12-02 23:33:01 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 527 bytes |
コンパイル時間 | 3,636 ms |
コンパイル使用メモリ | 252,432 KB |
最終ジャッジ日時 | 2025-01-26 02:53:15 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#include <bits/stdc++.h>using namespace std;#include <atcoder/all>using namespace atcoder;#define ll long long#define rep(i, n) for (int i = 0; i < (n); i++)#define P pair<int, int>#define LP pair<ll, ll>int main() {string x;cin >> x;sort(x.begin(), x.end());reverse(x.begin(), x.end());for (int i = x.size()-1; i >= 1; i--) {if (x[i] != x[i-1]) {if (i-1>0 || x[i] != '0') {swap(x[i],x[i-1]);cout << x << endl;return 0;}}}cout << -1 << endl;}