結果

問題 No.267 トランプソート
ユーザー masamasa
提出日時 2015-08-21 22:46:36
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,356 bytes
コンパイル時間 604 ms
コンパイル使用メモリ 69,272 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-25 14:59:20
合計ジャッジ時間 1,599 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
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 <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());

	cout << d.size() << endl;

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