結果
| 問題 | 
                            No.267 トランプソート
                             | 
                    
| コンテスト | |
| ユーザー | 
                             HAHAHA
                         | 
                    
| 提出日時 | 2015-08-24 13:10:30 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 1,000 ms | 
| コード長 | 3,220 bytes | 
| コンパイル時間 | 767 ms | 
| コンパイル使用メモリ | 90,840 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-18 13:08:26 | 
| 合計ジャッジ時間 | 1,477 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 20 | 
ソースコード
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<utility>
#include <fstream>
#include<set>
#include<map>
#include<cctype>
#include<cmath>
#include<algorithm>
using namespace std;
#define RALL(x) (x).rbegin(),(x).rend()
#define ALL(x) (x).begin(),(x).end()
#define repp(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define clr(a) memset((a), 0 ,sizeof(a))
typedef pair<int,int> P;
typedef vector<pair<int,string> > pii;
typedef map<string,int> mdi;
int main(){
	vector<int> vc,vc2,vc3,vc4;
	bool ok=false,ok2=false,ok3=false,ok4=false;
	int n,x=0;
	string s;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> s;
		if(s[0]=='D'){
			if(s[1]=='A') vc.push_back(1);
			else if(s[1]=='T') vc.push_back(10);
			else if(s[1]=='J') vc.push_back(11);
			else if(s[1]=='Q') vc.push_back(12);
			else if(s[1]=='K') vc.push_back(13);
			else vc.push_back(s[1]-'0');
		}
		else if(s[0]=='C'){
			if(s[1]=='A') vc2.push_back(1);
			else if(s[1]=='T') vc2.push_back(10);
			else if(s[1]=='J') vc2.push_back(11);
			else if(s[1]=='Q') vc2.push_back(12);
			else if(s[1]=='K') vc2.push_back(13);
			else vc2.push_back(s[1]-'0');
		}
		
		else if(s[0]=='H'){
			if(s[1]=='A') vc3.push_back(1);
			else if(s[1]=='T') vc3.push_back(10);
			else if(s[1]=='J') vc3.push_back(11);
			else if(s[1]=='Q') vc3.push_back(12);
			else if(s[1]=='K') vc3.push_back(13);
			else vc3.push_back(s[1]-'0');
		}
		
		else if(s[0]=='S'){
			if(s[1]=='A') vc4.push_back(1);
			else if(s[1]=='T') vc4.push_back(10);
			else if(s[1]=='J') vc4.push_back(11);
			else if(s[1]=='Q') vc4.push_back(12);
			else if(s[1]=='K') vc4.push_back(13);
			else vc4.push_back(s[1]-'0');
		}
		
		sort(ALL(vc));
		sort(ALL(vc2));
		sort(ALL(vc3));
		sort(ALL(vc4));
	}
	for(int i=0;i<vc.size();i++){
		if(i>0) cout << " ";
		x=1;
		ok=true;
		cout << "D";
		if(vc[i]==1)
			cout << "A";
		else if(vc[i]==10)
			cout << "T";
		else if(vc[i]==11)
			cout << "J";
		else if(vc[i]==12)
			cout << "Q";
		else if(vc[i]==13)
			cout << "K";
		else 
			cout << vc[i];
	}
	
	for(int i=0;i<vc2.size();i++){
		if(ok&&x<2)cout << " ";
		ok2=true;
		x=2;
		if(i>0) cout << " ";
		cout << "C";
		if(vc2[i]==1)
			cout << "A";
		else if(vc2[i]==10)
			cout << "T";
		else if(vc2[i]==11)
			cout << "J";
		else if(vc2[i]==12)
			cout << "Q";
		else if(vc2[i]==13)
			cout << "K";
		else 
			cout << vc2[i];
	}
	
	for(int i=0;i<vc3.size();i++){
		if((ok||ok)&&x<3) cout << " ";
		ok3=true;
		x=3;
		if(i>0) cout << " ";
		cout << "H";
		if(vc3[i]==1)
			cout << "A";
		else if(vc3[i]==10)
			cout << "T";
		else if(vc3[i]==11)
			cout << "J";
		else if(vc3[i]==12)
			cout << "Q";
		else if(vc3[i]==13)
			cout << "K";
		else 
			cout << vc3[i];
	}
	
	for(int i=0;i<vc4.size();i++){
		if((ok||ok2||ok3)&&x<4) cout << " ";
		x=4;
		if(i>0) cout << " ";
		cout << "S";
		if(vc4[i]==1)
			cout << "A";
		else if(vc4[i]==10)
			cout << "T";
		else if(vc4[i]==11)
			cout << "J";
		else if(vc4[i]==12)
			cout << "Q";
		else if(vc4[i]==13)
			cout << "K";
		else 
			cout << vc4[i];
	}
	cout << endl;
	return 0;
}
            
            
            
        
            
HAHAHA