結果
問題 | No.267 トランプソート |
ユーザー |
![]() |
提出日時 | 2015-08-27 13:39:37 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 997 bytes |
コンパイル時間 | 791 ms |
コンパイル使用メモリ | 71,516 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-18 14:59:32 |
合計ジャッジ時間 | 1,383 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <iostream>#include <vector>#include <string>#include <algorithm>using namespace std;int main() {int N;cin >> N;vector<pair<string, int>> x(N);for (int i = 0; i < N; ++i) {string t;cin >> t;int num = 0;// ダイヤ、クローバー、ハート、スペードswitch (t[0]) {case 'D': num = 13 * 0; break;case 'C': num = 13 * 1; break;case 'H': num = 13 * 2; break;case 'S': num = 13 * 3; break;}// A:1、T:10、J:11、Q:12、K:13switch (t[1]) {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 += t[1] - '0'; break;}x[i] = pair<string, int>(t, num);}sort(x.begin(), x.end(), [](const pair<string, int>& a, const pair<string, int>& b) {return a.second < b.second;});for (int i = 0; i < N; ++i) {cout << x[i].first;if (i != N - 1) {cout << " ";} else {cout << endl;}}}