結果
| 問題 | No.267 トランプソート |
| コンテスト | |
| ユーザー |
rsk0315
|
| 提出日時 | 2019-05-18 16:29:37 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 950 bytes |
| 記録 | |
| コンパイル時間 | 727 ms |
| コンパイル使用メモリ | 95,656 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-07 11:52:14 |
| 合計ジャッジ時間 | 1,708 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
#include <cstdio>
#include <cctype>
#include <vector>
#include <string>
#include <algorithm>
struct {
int M_num(char x) const {
if (isdigit(x)) return x-'0';
if (x == 'A') return 1;
if (x == 'T') return 10;
if (x == 'J') return 11;
if (x == 'Q') return 12;
if (x == 'K') return 13;
return -1;
}
int M_suit(char x) const {
if (x == 'D') return 0;
if (x == 'C') return 1;
if (x == 'H') return 2;
if (x == 'S') return 3;
return -1;
}
bool operator ()(const std::string& x, const std::string& y) const {
if (x[0] != y[0]) return M_suit(x[0]) < M_suit(y[0]);
return M_num(x[1]) < M_num(y[1]);
}
} cmp;
int main() {
size_t n;
scanf("%zu", &n);
std::vector<std::string> a(n);
for (auto& ai: a) {
char buf[3];
scanf("%s", buf);
ai = buf;
}
std::sort(a.begin(), a.end(), cmp);
for (size_t i = 0; i < n; ++i)
printf("%s%c", a[i].c_str(), i+1<n? ' ':'\n');
}
rsk0315