結果

問題 No.267 トランプソート
ユーザー pekempeypekempey
提出日時 2015-08-21 22:30:12
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,368 bytes
コンパイル時間 1,381 ms
コンパイル使用メモリ 161,156 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 14:45:29
合計ジャッジ時間 2,386 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a) rep2 (i, 0, a)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a) repr2 (i, 0, a)
#define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define asn(a, b, c) fill_n(&(b), sizeof(a) / sizeof(b), c)
using namespace std;
typedef long long ll;
const ll inf = 1e9;
const ll mod = 1e9 + 7;

int main() {
	int N;
	cin >> N;
	vector<pair<int, int>> v;
	map<char, int> t;
	t['D'] = 0;
	t['C'] = 1;
	t['H'] = 2;
	t['S'] = 3;
	rep (i, N) {
		string m;
		cin >> m;
		int a = t[m[0]];
		int b;
		if (m[1] == 'A') {
			b = 1;
		} else if (m[1] == 'T') {
			b = 10;
		} else if (m[1] == 'J') {
			b = 11;
		} else if (m[1] == 'Q') {
			b = 12;
		} else if (m[1] == 'K') {
			b = 13;
		} else {
			b = m[1] - '0';
		}
		v.emplace_back(a, b);
	}
	sort(v.begin(), v.end());

	rep (i, N) {
		string s;
		if (v[i].first == 0) {
			s += 'D';
		} else if (v[i].first == 1) {
			s += 'C';
		} else if (v[i].first == 2) {
			s += 'H';
		} else if (v[i].first == 3) {
			s += 'S';
		}

		if (v[i].second == 1) {
			s += 'A';	
		} else if (v[i].second == 10) {
			s += 'T';
		} else if (v[i].second == 11) {
			s += 'J';
		} else if (v[i].second == 12) {
			s += 'Q';
		} else if (v[i].second == 13) {
			s += 'K';
		} else {
			s += v[i].second + '0';
		}

		if (i) cout << " ";
		cout << s;
	}
	cout << endl;

	return 0;
}
0