結果

問題 No.267 トランプソート
ユーザー masamasa
提出日時 2015-08-21 22:49:26
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,328 bytes
コンパイル時間 651 ms
コンパイル使用メモリ 69,592 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-25 15:01:33
合計ジャッジ時間 1,653 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

bool first;

void show(vector<int> vec, char mark) {
	char c;

	for (int i = 0; i < vec.size(); i++) {
		switch (vec[i]) {
			case  1: c = 'A'; break;
			case 10: c = 'T'; break;
			case 11: c = 'J'; break;
			case 12: c = 'Q'; break;
			case 13: c = 'K'; break;
			default: c = vec[i] + '0'; break;
		}

		if (!first) {
			cout << " ";
		}
		cout << mark << c;
		first = false;
	}
}

int main() {
	int n;
	string card;

	cin >> n;
	vector<int> d, c, h, s;

	char suit, num_c;
	int num;

	for (int i = 0; i < n; i++) {
		cin >> card;

		suit = card[0];
		num_c = card[1];
		switch(num_c) {
			case 'A': num =  1; break;
			case 'T': num = 10; break;
			case 'J': num = 11; break;
			case 'Q': num = 12; break;
			case 'K': num = 13; break;
			default: num = num_c - '0'; break;
		}

		switch(suit) {
			case 'D': d.push_back(num); break;
			case 'C': c.push_back(num); break;
			case 'H': h.push_back(num); break;
			case 'S': s.push_back(num); break;
			default: break;
		}
	}

	sort(d.begin(), d.end());
	sort(c.begin(), c.end());
	sort(h.begin(), h.end());
	sort(s.begin(), s.end());

	first = true;
	show(d, 'D');
	show(c, 'C');
	show(h, 'H');
	show(s, 'S');
	cout << endl;
	return 0;
}
0