結果

問題 No.267 トランプソート
ユーザー zaichuzaichu
提出日時 2016-01-08 00:54:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 741 bytes
コンパイル時間 1,371 ms
コンパイル使用メモリ 165,196 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 16:45:34
合計ジャッジ時間 2,424 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
	int n;
	cin >> n;
	string mark = "DCHS";
	string num = "0A23456789TJQK";
	vector<int> data(n);
	char x,y;
	int ret;
	for(int i = 0; i < n; i++){
		cin >> x >> y;
		if(x == 'D') ret = 0;
		else if(x == 'C') ret = 13;
		else if(x == 'H') ret = 26;
		else ret = 39;
		if(y == 'A') ret += 1;
		else if(y == 'T') ret += 10;
		else if(y == 'J') ret += 11;
		else if(y == 'Q') ret += 12;
		else if(y == 'K') ret += 13;
		else ret += y - '0';
		data[i] = ret;
	}
	sort(data.begin(),data.end());
	for(int i = 0; i < n; i++){
		if(i) cout << " ";
		if(data[i]%13 != 0 ) cout << mark[data[i]/13] << num[data[i]%13];
		else cout << mark[data[i]/13-1] << "K";
	}
	cout << endl;			
	return 0;
}
0