結果
問題 |
No.39 桁の数字を入れ替え
|
ユーザー |
![]() |
提出日時 | 2020-10-11 14:51:31 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 542 bytes |
コンパイル時間 | 2,012 ms |
コンパイル使用メモリ | 198,852 KB |
最終ジャッジ日時 | 2025-01-15 06:37:29 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> #define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false)) using namespace std; int main() { fastIO; string src; cin >> src; vector<int> res; res.emplace_back(stoi(src)); for (size_t i = 0; i < src.size() - 1; ++i) { for (size_t j = i + 1; j < src.size(); ++j) { string copy = src; char temp = copy[i]; copy[i] = copy[j]; copy[j] = temp; res.emplace_back(stoi(copy)); } } sort(res.begin(), res.end()); cout << res.back() << '\n'; return 0; }