結果

問題 No.267 トランプソート
ユーザー なおなお
提出日時 2015-12-16 16:39:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 853 bytes
コンパイル時間 1,436 ms
コンパイル使用メモリ 155,812 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-14 10:47:28
合計ジャッジ時間 2,692 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int(i)=0;(i)<(n);++(i))
#define in(T,V) T V;cin>>V;

int f0(char c){
    switch(c){
    case 'D': return 0;
    case 'C': return 1;
    case 'H': return 2;
    case 'S': return 3;
    }
    return -1;
}
int f1(char c){
    switch(c){
    case 'A': return 1;
    case 'T': return 10;
    case 'J': return 11;
    case 'Q': return 12;
    case 'K': return 13;
    }
    return c - '0';
}

int main(){
    vector<string> v;
    in(int,N);
    REP(i,N){
        in(string,s); v.push_back(s);
    }
    sort(v.begin(), v.end(), [](const string &s, const string &t){
        int s0=f0(s[0]), t0=f0(t[0]);
        if(s0!=t0)return s0<t0;
        int s1=f1(s[1]), t1=f1(t[1]);
        return s1<t1;
    });
    REP(i,N){
        cout << v[i] << (i<N-1?" ":"\n");
    }
}
0