結果
問題 | No.267 トランプソート |
ユーザー |
|
提出日時 | 2015-08-21 22:49:26 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,328 bytes |
コンパイル時間 | 635 ms |
コンパイル使用メモリ | 67,512 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-18 11:48:52 |
合計ジャッジ時間 | 1,374 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <iostream>#include <cstdio>#include <vector>#include <algorithm>#include <utility>#include <string>using namespace std;bool first;void show(vector<int> vec, char mark) {char c;for (int i = 0; i < vec.size(); i++) {switch (vec[i]) {case 1: c = 'A'; break;case 10: c = 'T'; break;case 11: c = 'J'; break;case 12: c = 'Q'; break;case 13: c = 'K'; break;default: c = vec[i] + '0'; break;}if (!first) {cout << " ";}cout << mark << c;first = false;}}int main() {int n;string card;cin >> n;vector<int> d, c, h, s;char suit, num_c;int num;for (int i = 0; i < n; i++) {cin >> card;suit = card[0];num_c = card[1];switch(num_c) {case 'A': num = 1; break;case 'T': num = 10; break;case 'J': num = 11; break;case 'Q': num = 12; break;case 'K': num = 13; break;default: num = num_c - '0'; break;}switch(suit) {case 'D': d.push_back(num); break;case 'C': c.push_back(num); break;case 'H': h.push_back(num); break;case 'S': s.push_back(num); break;default: break;}}sort(d.begin(), d.end());sort(c.begin(), c.end());sort(h.begin(), h.end());sort(s.begin(), s.end());first = true;show(d, 'D');show(c, 'C');show(h, 'H');show(s, 'S');cout << endl;return 0;}