結果

問題 No.39 桁の数字を入れ替え
ユーザー satanicsatanic
提出日時 2016-03-14 04:28:44
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,260 bytes
コンパイル時間 1,341 ms
コンパイル使用メモリ 67,608 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-26 04:08:28
合計ジャッジ時間 2,209 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
4,348 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);

	char tmp;
	std::vector<int> input;
	while (std::cin >> tmp) {
		input.push_back(tmp-'0');
	}
	std::vector<int> max_checker(input);
	while(true) {
		for (auto it = max_checker.begin() + 1; it != max_checker.end(); ++it) {
			if (max_checker.front() < *it) {
				goto CHECK;
			}
		}
		max_checker.erase(max_checker.begin());
		if (max_checker.empty()) goto OUTPUT;
	}
CHECK:///////////////////////////////////////goto CHECK
	std::sort(max_checker.begin(), max_checker.end());
	std::reverse(max_checker.begin(), max_checker.end());
	for (auto it = max_checker.rbegin(); it != max_checker.rend(); ++it) {
		if (*it == max_checker.front()) {
			for (auto it2 = max_checker.begin(); it2 != max_checker.end(); ++it2) {
				if (*it2 != max_checker.front() || *it == *it2) {
					std::swap(*it, *it2);
					auto it3 = input.rbegin();
					for (auto it4 = max_checker.rbegin(); it4 != max_checker.rend(); ++it4, ++it3) {
						*it3 = *it4;
					}
					goto OUTPUT;
				}
			}
		}
	}
OUTPUT:////////////////////////////////////////goto OUTPUT
	for (auto it : input) {
		std::cout << it;
	}
	std::cout << "\n";

	return 0;
}
0