結果

問題 No.1729 ~サンプルはちゃんと見て!~ 16進数と8進数(1)
ユーザー mmn15277198mmn15277198
提出日時 2021-11-17 05:23:19
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,572 bytes
コンパイル時間 1,009 ms
コンパイル使用メモリ 102,828 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-23 13:43:59
合計ジャッジ時間 2,577 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
#include <cstdio>

using namespace std;

int main() {
  string s;
  cin >> s;
  string t;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A') t += "1010";
    if (s[i] == 'B') t += "1011";
    if (s[i] == 'C') t += "1100";
    if (s[i] == 'D') t += "1101";
    if (s[i] == 'E') t += "1110";
    if (s[i] == 'F') t += "1111";
  }
  if (t.size() % 3 == 1) t = "00" + t;
  else if (t.size() % 3 == 2) t = "0" + t;
  string ans;
  for (int i = 0; i < t.size(); i += 3) {
    string x = t.substr(i , 3);
    if (x == "000") {
      ans += '0';
    } else if (x == "001") {
      ans += '1';
    } else if (x == "010") {
      ans += '2';
    } else if (x == "011") {
      ans += '3';
    } else if (x == "100") {
      ans += '4';
    } else if (x == "101") {
      ans += '5';
    } else if (x == "110") {
      ans += '6';
    } else if (x == "111") {
      ans += '7';
    }
  }
  vector<int> cnt(8 , 0);
  for (int i = 0; i < ans.size(); i++) {
    cnt[ans[i] - '0']++;
  }
  vector<pair<int,int> > p(8);
  for (int i = 0; i < 8; i++) {
    p[i] = make_pair(cnt[i] , -i);
  }
  sort(p.begin() , p.end());
  reverse(p.begin() , p.end());
  for (int i = 0; i < 8; i++) {
    if (i == 0) {
      cout << -p[i].second;
    } else {
      if (p[i].first != p[i - 1].first) {
        cout << endl;
        break;
      } else {
        cout << -p[i].second;
      }
    }
    cout << " ";
  }
  return 0;
}
0