結果

問題 No.267 トランプソート
ユーザー ohreitetsuohreitetsu
提出日時 2018-06-06 18:07:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,292 bytes
コンパイル時間 955 ms
コンパイル使用メモリ 79,628 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-12 22:47:09
合計ジャッジ時間 1,826 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
struct X{
	char m;
	char n;
	string v;
	X(){}
	void setV(char _m,char _n,string _v){
		m=_m;
		n=_n;
		v=_v;
	}
};
bool Comp(X& l,X &r){
	string ls,rs;
	switch(l.m){
	case 'D':
		ls='a';
		break;
	case 'C':
		ls='b';
		break;
	case 'H':
		ls='c';
		break;
	case 'S':
		ls='d';
		break;
	}	
	switch(r.m){
	case 'D':
		rs='a';
		break;
	case 'C':
		rs='b';
		break;
	case 'H':
		rs='c';
		break;
	case 'S':
		rs='d';
		break;
	}
	switch(l.n){
	case 'A':
		ls+='1';
		break;
	case 'T':
		ls+='A';
		break;
	case 'J':
		ls+='B';
		break;
	case 'Q':
		ls+='C';
		break;
	case 'K':
		ls+='D';
		break;
	default:
		ls+=l.n;
		break;
	}
	switch(r.n){
	case 'A':
		rs+='1';
		break;
	case 'T':
		rs+='A';
		break;
	case 'J':
		rs+='B';
		break;
	case 'Q':
		rs+='C';
		break;
	case 'K':
		rs+='D';
		break;
	default:
		rs+=r.n;
		break;
	}
	int comp=ls.compare(rs);
	if (comp<0){
		return true;
	}else{
		return false;
	}
}
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	vector<X> X(N);
	int i;
	string mn;
	for (i=0;i<N;i++){
		cin>>mn;
		X[i].setV(mn[0],mn[1],mn);
	}
	sort(X.begin(),X.end(),Comp);
	for (i=0;i<N;i++){
		cout<<X[i].v;
		if (i<N-1){
			cout<<" ";
		}
	}
	cout<<endl;
	return 0;
}
0