結果

問題 No.267 トランプソート
ユーザー naimonon77naimonon77
提出日時 2015-10-16 18:40:46
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,297 bytes
コンパイル時間 419 ms
コンパイル使用メモリ 59,208 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-28 22:06:35
合計ジャッジ時間 1,466 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
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 <iostream>
#include <algorithm>
#include <string>
using namespace std;

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define SQR(X) ((X)*(X))

typedef long long ll;
typedef unsigned long long ull;
typedef long double lb;
/* ここからが本編 */

typedef struct{
   char s[10];
   int a;
}card_sort;
void card_num(card_sort card)
{
   if('1' <= card.s[1] && card.s[1] <= '9') {
      card.a += card.s[1] -  '0';
      return;
   }
   switch(card.s[1]) {
   case 'A': card.a += 1;break;
   case 'T': card.a += 10;break;
   case 'J': card.a += 11;break;
   case 'Q': card.a += 12;break;
   case 'K': card.a += 13;break;
   }
}
int cmp(const card_sort *x,const card_sort *y)
{
   return  (x->a < y->a ? -1 :
            x->a > y->a ? 1 : 0);
}
int main(void)
{
   int i,j;
   int n;
   card_sort card[60];
   cin >> n;
   rep(i,n) {
      cin >> card[i].s;
      switch(card[i].s[0]){
      case 'D': card[i].a = 0; break;
      case 'C': card[i].a = 20; break;
      case 'H': card[i].a = 40; break;
      case 'S': card[i].a = 60; break;
      }
      card_num(card[i]);
   }
   qsort(card,n,sizeof(card[0])
      ,(int(*)(const void*, const void*))cmp);
   cout << card[0].s;
   for(i=1;i<n;i++) {
      cout << ' ' << card[i].s;
   }
   cout << endl;
   return 0;
}
0