結果

問題 No.267 トランプソート
ユーザー alpha_virginisalpha_virginis
提出日時 2015-08-21 22:30:33
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,379 bytes
コンパイル時間 1,628 ms
コンパイル使用メモリ 152,556 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 14:46:58
合計ジャッジ時間 2,432 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <cstdint>
#include <sys/time.h>

typedef std::int_fast32_t  s32;
typedef std::uint_fast32_t u32;
typedef std::int_fast64_t  s64;
typedef std::uint_fast64_t u64;

const unsigned long mod = 1000000007;

typedef std::pair<int, int> Card;

Card stoc(std::string str) {
  Card card;
  switch( str[0] ) {
  case 'D' :
    card.first = 0;
    break;
  case 'C' :
    card.first = 1;
    break;
  case 'H' :
    card.first = 2;
    break;
  case 'S' :
    card.first = 3;
    break;
  }
  switch( str[1] ) {
  case 'A' :
    card.second = 1;
    break;
  case '2' ... '9' :
    card.second = str[1] - '0';
    break;
  case 'T' :
    card.second = 10;
    break;
  case 'J' :
    card.second = 11;
    break;
  case 'Q' :
    card.second = 12;
    break;
  case 'K' :
    card.second = 13;
    break;
  }
  return card;
}

int main() {

  int N;  
  std::cin >> N;
  
  std::vector<Card> vc;

  std::string str;
  for(int i = 0; i < N; ++i) {
    std::cin >> str;
    vc.push_back(stoc(str));
  }

  std::sort(vc.begin(), vc.end());

  char type[4] = {'D', 'C', 'H', 'S'};
  char num[]   = {'0', 'A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K'};

  for(int i = 0; i < N-1; ++i) {
    std::cout << type[vc[i].first] << num[vc[i].second] << " ";
  }
  std::cout << type[vc[N-1].first] << num[vc[N-1].second] << std::endl;
  
  return 0;
}
0