結果

問題 No.267 トランプソート
ユーザー rsk0315rsk0315
提出日時 2019-05-18 16:27:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 951 bytes
コンパイル時間 894 ms
コンパイル使用メモリ 76,576 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 07:38:18
合計ジャッジ時間 1,839 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cctype>
#include <vector>
#include <string>
#include <algorithm>

struct {
  int M_num(char x) const {
    if (isdigit(x)) return x-'0';
    if (x == 'A') return 1;
    if (x == 'T' ) return 10;
    if (x == 'J') return 11;
    if (x == 'Q') return 12;
    if (x == 'K') return 13;
    return -1;
  }
  int M_suit(char x) const {
    if (x == 'D') return 0;
    if (x == 'C') return 1;
    if (x == 'H') return 2;
    if (x == 'S') return 3;
    return -1;
  }
  bool operator ()(const std::string& x, const std::string& y) const {
    if (x[1] != y[1]) return M_num(x[1]) < M_num(y[1]);
    return M_suit(x[0]) < M_suit(y[0]);
  }
} cmp;

int main() {
  size_t n;
  scanf("%zu", &n);

  std::vector<std::string> a(n);
  for (auto& ai: a) {
    char buf[3];
    scanf("%s", buf);
    ai = buf;
  }

  std::sort(a.begin(), a.end(), cmp);
  for (size_t i = 0; i < n; ++i)
    printf("%s%c", a[i].c_str(), i+1<n? ' ':'\n');
}
0