結果

問題 No.267 トランプソート
ユーザー forest3
提出日時 2025-03-26 21:21:55
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 931 bytes
コンパイル時間 2,261 ms
コンパイル使用メモリ 185,604 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2025-03-26 21:22:00
合計ジャッジ時間 3,678 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)

int main() {
	int N;
	cin >> N;
	map<char, int> mp, mp1;
	mp['D'] = 0;
	mp['C'] = 1;
	mp['H'] = 2;
	mp['S'] = 3;
	mp1['A'] = 1;
	mp1['T'] = 10;
	mp1['J'] = 11;
	mp1['Q'] = 12;
	mp1['K'] = 13;
	map<int, char> rmp, rmp1;
	rmp[0] = 'D';
	rmp[1] = 'C';
	rmp[2] = 'H';
	rmp[3] = 'S';
	rmp1[1] = 'A';
	rmp1[10] = 'T';
	rmp1[11] = 'J';
	rmp1[12] = 'Q';
	rmp1[13] = 'K';
	using P = pair<int, int>;
	vector<P> c(N);
	rep(i, N) {
		string s;
		cin >> s;
		c[i].first = mp[s[0]];
		if(mp1.count(s[1])) c[i].second = mp1[s[1]];
		else c[i].second = s[1] - '0';
	}
	sort(c.begin(), c.end());
	vector<string> ans;
	rep(i, N) {
		string s;
		s += rmp[c[i].first];
		if(rmp1.count(c[i].second)) s += rmp1[c[i].second];
		else s += (char)(c[i].second + '0');
		ans.push_back(s);
	}
	rep(i, N) cout << ans[i] << " ";
	cout << endl;
}
0