結果

問題 No.267 トランプソート
ユーザー evawenis
提出日時 2020-08-17 23:25:10
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 614 bytes
コンパイル時間 2,460 ms
コンパイル使用メモリ 207,060 KB
最終ジャッジ日時 2025-01-13 02:44:56
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	string num="A23456789TJQK"s;
	unordered_map<char,int>cton;
	for(int i=0;i<13;++i){
		cton[num.at(i)]=i;
	}
	unordered_map<char,priority_queue<int,vector<int>,greater<int>>>c;
	for(int i=0;i<n;++i){
		char m,n; cin>>m>>n;
		c[m].push(cton[n]);
	}
	string ord="DCHS"s;
	for(auto&&i:ord){
		while(c[i].size()){
			cout<<i<<num.at(c[i].top());
			c[i].pop();
			goto out;
		}
	}
	out:
	for(auto&&i:ord){
		while(c[i].size()){
			cout<<" "s<<i<<num.at(c[i].top());
			c[i].pop();
		}
	}
	cout<<"\n"s;
}
0