結果

問題 No.267 トランプソート
ユーザー HAHAHAHAHAHA
提出日時 2015-08-24 13:10:30
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 3,220 bytes
コンパイル時間 2,457 ms
コンパイル使用メモリ 85,544 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 16:41:33
合計ジャッジ時間 2,019 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#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;
}
0