結果
| 問題 |
No.267 トランプソート
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-12-16 16:39:47 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 853 bytes |
| コンパイル時間 | 1,766 ms |
| コンパイル使用メモリ | 170,868 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-16 05:41:07 |
| 合計ジャッジ時間 | 2,767 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int(i)=0;(i)<(n);++(i))
#define in(T,V) T V;cin>>V;
int f0(char c){
switch(c){
case 'D': return 0;
case 'C': return 1;
case 'H': return 2;
case 'S': return 3;
}
return -1;
}
int f1(char c){
switch(c){
case 'A': return 1;
case 'T': return 10;
case 'J': return 11;
case 'Q': return 12;
case 'K': return 13;
}
return c - '0';
}
int main(){
vector<string> v;
in(int,N);
REP(i,N){
in(string,s); v.push_back(s);
}
sort(v.begin(), v.end(), [](const string &s, const string &t){
int s0=f0(s[0]), t0=f0(t[0]);
if(s0!=t0)return s0<t0;
int s1=f1(s[1]), t1=f1(t[1]);
return s1<t1;
});
REP(i,N){
cout << v[i] << (i<N-1?" ":"\n");
}
}