結果
| 問題 | No.267 トランプソート |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-06-04 10:52:19 |
| 言語 | D (dmd 2.112.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 1,000 ms |
| コード長 | 806 bytes |
| 記録 | |
| コンパイル時間 | 4,375 ms |
| コンパイル使用メモリ | 195,328 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-04 10:52:25 |
| 合計ジャッジ時間 | 5,378 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
| 純コード判定待ち |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
module main;
import std;
// トランプカードの構造体
struct Card {
char suit;
char number;
this(string s)
{
suit = s[0];
number = s[1];
}
int opCmp(ref const Card rhs)
{
static suits = ['D' : 0, 'C' : 1, 'H' : 2, 'S' : 3];
static numbers = [
'A' : 1, '2' : 2, '3' : 3, '4' : 4, '5' : 5, '6' : 6, '7' : 7,
'8' : 8, '9' : 9, 'T' : 10, 'J' : 11, 'Q' : 12, 'K' : 13
];
if (suit != rhs.suit)
return suits[suit] - suits[rhs.suit];
if (number != rhs.number)
return numbers[number] - numbers[rhs.number];
return 0;
}
string toString()
{
return [suit, number].idup;
}
}
void main()
{
// 入力
int N = readln.chomp.to!int;
auto cards = readln.split.map!(s => Card(s)).array;
// 答えの計算
cards.sort;
// 答えの出力
writefln("%(%s %)", cards);
}