結果
| 問題 |
No.256 桁の数字を入れ替え (2)
|
| コンテスト | |
| ユーザー |
chiyoda
|
| 提出日時 | 2016-06-25 21:09:39 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 652 bytes |
| コンパイル時間 | 506 ms |
| コンパイル使用メモリ | 62,572 KB |
| 最終ジャッジ日時 | 2024-11-14 19:45:30 |
| 合計ジャッジ時間 | 855 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:26:50: error: no match for ‘operator--’ (operand type is ‘std::__detail::_Node_iterator<std::pair<const char, int>, false, false>’)
26 | for (auto itr = cnt.end(); itr != cnt.begin(); --itr) {
| ^~~~~
ソースコード
#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;
int main() {
unordered_map<char, int> cnt;
cnt['0'] = 0;
cnt['1'] = 0;
cnt['2'] = 0;
cnt['3'] = 0;
cnt['4'] = 0;
cnt['5'] = 0;
cnt['6'] = 0;
cnt['7'] = 0;
cnt['8'] = 0;
cnt['9'] = 0;
string n;
cin >> n;
for (auto itr = cnt.begin(); itr != cnt.end(); ++itr) {
for (int j = 0, size = n.size(); j < size; ++j) {
if (itr->first == n[j]) itr->second++;
}
}
for (auto itr = cnt.end(); itr != cnt.begin(); --itr) {
for (int j = 0; j < itr->second; ++j) {
cout << itr->first;
}
}
cout << endl;
return 0;
}
chiyoda