結果
問題 |
No.927 Second Permutation
|
ユーザー |
|
提出日時 | 2019-11-22 21:35:06 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 696 bytes |
コンパイル時間 | 1,100 ms |
コンパイル使用メモリ | 101,172 KB |
最終ジャッジ日時 | 2025-01-08 04:40:40 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 17 |
ソースコード
#include <iostream> #include <iomanip> #include <vector> #include <algorithm> #include <utility> #include <string> #include <cstdlib> #include <queue> #include <map> using namespace std; typedef long long int ll; typedef pair<int, int> Pii; const ll mod = 1000000007; int main() { cin.tie(0); ios::sync_with_stdio(false); string x; cin >> x; int l = x.length(); map<char, int> count; for (auto &c: x) count[c]++; if (count.size() == 1 || count['0'] >= l-1) { cout << -1 << endl; // impossible return 0; } sort(x.begin(), x.end()); int p = 1; while (x[p] == x[0]) p++; swap(x[0], x[p]); reverse(x.begin(), x.end()); cout << x << endl; return 0; }