結果

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

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

#define mp       make_pair
#define mt	 make_tuple
#define pb       push_back
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    pair<int,int>      pii;
typedef    pair<long,long>    pll;

const int INF=1<<29;
const double EPS=1e-9;
const int MOD = 100000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int N;
vector<pair<int, int>> card;
char mark[4] = {'D', 'C', 'H', 'S'};
map<char, int> digits;
map<int, char> dicdigits;
int main(){
  cin >> N;
  digits['A'] = 1;
  digits['T'] = 10;
  digits['J'] = 11;
  digits['Q'] = 12;
  digits['K'] = 13;

  dicdigits[1] = 'A';
  dicdigits[10] = 'T';
  dicdigits[11] = 'J';
  dicdigits[12] = 'Q';
  dicdigits[13] = 'K';

  for (int i = 2; i <= 9; i++){
    digits[i + '0'] = i;
    dicdigits[i] = i + '0';
  }
  for (int i = 0; i < N; i++){
    string tmp;
    cin >> tmp;
    string t = tmp.substr(1).c_str();
    char c = t[0];
    int digit = digits[c];
    if (tmp[0] == 'D'){
      card.push_back(mp(0, digit));
    }
    if (tmp[0] == 'C'){
      card.push_back(mp(1, digit));
    }
    if (tmp[0] == 'H'){
      card.push_back(mp(2, digit));
    }
    if (tmp[0] == 'S'){
      card.push_back(mp(3, digit));
    }
  }
  sort(card.begin(), card.end());
  for (int i = 0; i < card.size(); i++){
    if (i != card.size() - 1){
      cout << mark[card[i].first] << dicdigits[card[i].second] << " ";
    }else{
      cout << mark[card[i].first] << dicdigits[card[i].second] << endl;
    }
  }
}
0