結果

問題 No.267 トランプソート
ユーザー maine_honzuki
提出日時 2021-05-06 23:18:30
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 14 ms / 1,000 ms
コード長 1,058 bytes
コンパイル時間 2,365 ms
コンパイル使用メモリ 205,444 KB
最終ジャッジ日時 2025-01-21 07:48:23
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

//https://ncode.syosetu.com/n4830bu/267/
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<string> V(N);
    for (auto&& x : V) {
        cin >> x;
    }
    auto maine = [](string s) {
        int ret = 0;
        if (s[0] == 'D')
            ret = 0;
        else if (s[0] == 'C')
            ret = 100;
        else if (s[0] == 'H')
            ret = 200;
        else if (s[0] == 'S')
            ret = 300;
        else
            assert(false);
        if (isdigit(s[1]))
            ret += s[1] - '0';
        else if (s[1] == 'A')
            ret += 1;
        else if (s[1] == 'T')
            ret += 10;
        else if (s[1] == 'J')
            ret += 11;
        else if (s[1] == 'Q')
            ret += 12;
        else if (s[1] == 'K')
            ret += 13;
        else
            assert(false);
        return ret;
    };
    sort(V.begin(), V.end(), [&](string x, string y) { return maine(x) < maine(y); });
    for (int i = 0; i < N; i++) {
        cout << V[i] << " \n"[i == N - 1];
    }
}
0