結果
問題 | No.267 トランプソート |
ユーザー |
![]() |
提出日時 | 2015-08-21 22:35:25 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 736 bytes |
コンパイル時間 | 1,005 ms |
コンパイル使用メモリ | 88,132 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-18 11:44:14 |
合計ジャッジ時間 | 1,406 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <iostream> #include <vector> #include <cstdio> #include <sstream> #include <map> #include <string> #include <algorithm> #include <queue> #include <cmath> #include <set> using namespace std; map<int, int> m; bool comp(const string& a, const string& b){ if(m[a[0]] != m[b[0]]) return m[a[0]] < m[b[0]]; return m[a[1]] < m[b[1]]; } int main(){ int n; cin >> n; vector<string> v(n); for(int i=0; i<n; i++){ cin >> v[i]; } m['D'] = 0; m['C'] = 1; m['H'] = 2; m['S'] = 3; m['A'] = 1; for(int i=2; i<10; i++){ m[i+'0'] = i; } m['T'] = 10; m['J'] = 11; m['Q'] = 12; m['K'] = 13; sort(v.begin(), v.end(), comp); for(int i=0; i<n; i++){ printf("%s%s", v[i].c_str(), (i==n-1?"\n":" ")); } return 0; }