結果

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

テストケース

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

ソースコード

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