結果

問題 No.267 トランプソート
ユーザー ishizuishizu
提出日時 2015-08-21 22:31:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,280 bytes
コンパイル時間 894 ms
コンパイル使用メモリ 91,408 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 14:47:17
合計ジャッジ時間 1,886 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>

#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<functional>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 1<<30
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define ll long long
#define ull unsigned long long
map<char,int> card;
map<char,int> p; 
class cmp{
	public: bool operator()(const string& a,const string& b){
		int sa=a[1]-'0';
		int sb=b[1]-'0';
		if(sa=='A'-'0') sa=1;
		if(sa=='T'-'0') sa=10;
		if(sa=='J'-'0') sa=11;
		if(sa=='Q'-'0') sa=12;
		if(sa=='K'-'0') sa=13;
		if(sb=='A'-'0') sb=1;
		if(sb=='T'-'0') sb=10;
		if(sb=='J'-'0') sb=11;
		if(sb=='Q'-'0') sb=12;
		if(sb=='K'-'0') sb=13;

		if(a[0]!=b[0]){
			return card[a[0]] < card[b[0]];
		}else{
			return sa<sb;
		}

	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin>>n;
	vector<string> s(n);
	REP(i,n) cin>>s[i];
	card['D']=1;
	card['C']=2;
	card['H']=3;
	card['S']=4;
	sort(s.begin(),s.end(),cmp());
	REP(i,n) cout<<s[i]<<" ";
	cout<<endl;
}
0