結果
問題 | No.267 トランプソート |
ユーザー |
![]() |
提出日時 | 2015-08-21 22:30:33 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,379 bytes |
コンパイル時間 | 1,378 ms |
コンパイル使用メモリ | 165,896 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-18 11:37:32 |
合計ジャッジ時間 | 2,070 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h>#include <cstdint>#include <sys/time.h>typedef std::int_fast32_t s32;typedef std::uint_fast32_t u32;typedef std::int_fast64_t s64;typedef std::uint_fast64_t u64;const unsigned long mod = 1000000007;typedef std::pair<int, int> Card;Card stoc(std::string str) {Card card;switch( str[0] ) {case 'D' :card.first = 0;break;case 'C' :card.first = 1;break;case 'H' :card.first = 2;break;case 'S' :card.first = 3;break;}switch( str[1] ) {case 'A' :card.second = 1;break;case '2' ... '9' :card.second = str[1] - '0';break;case 'T' :card.second = 10;break;case 'J' :card.second = 11;break;case 'Q' :card.second = 12;break;case 'K' :card.second = 13;break;}return card;}int main() {int N;std::cin >> N;std::vector<Card> vc;std::string str;for(int i = 0; i < N; ++i) {std::cin >> str;vc.push_back(stoc(str));}std::sort(vc.begin(), vc.end());char type[4] = {'D', 'C', 'H', 'S'};char num[] = {'0', 'A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K'};for(int i = 0; i < N-1; ++i) {std::cout << type[vc[i].first] << num[vc[i].second] << " ";}std::cout << type[vc[N-1].first] << num[vc[N-1].second] << std::endl;return 0;}