結果
問題 | No.267 トランプソート |
ユーザー |
![]() |
提出日時 | 2015-09-06 23:24:36 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,900 bytes |
コンパイル時間 | 849 ms |
コンパイル使用メモリ | 79,136 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 04:45:19 |
合計ジャッジ時間 | 1,712 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
コンパイルメッセージ
main.cpp: In function ‘int func(char)’: main.cpp:34:1: warning: control reaches end of non-void function [-Wreturn-type] 34 | } | ^ main.cpp: In function ‘std::string func2(int)’: main.cpp:52:1: warning: control reaches end of non-void function [-Wreturn-type] 52 | } | ^
ソースコード
#include <iostream>#include <vector>#include <string>#include <cstring>#include <algorithm>#include <sstream>#include <map>#include <set>#define REP(i,k,n) for(int i=k;i<n;i++)#define rep(i,n) for(int i=0;i<n;i++)#define INF 1<<30#define pb push_back#define mp make_pairusing namespace std;typedef long long ll;typedef pair<int,int> P;int func(char c) {if('2' <= c && c <= '9') {return c - '0';} else if(c == 'A') {return 1;} else if(c == 'T') {return 10;} else if(c == 'J') {return 11;} else if(c == 'Q') {return 12;} else if(c == 'K') {return 13;}}string func2(int d) {if(2 <= d && d <= 9) {stringstream ss;ss << d;return ss.str();} else if(d == 1) {return "A";} else if(d == 10) {return "T";} else if(d == 11) {return "J";} else if(d == 12) {return "Q";} else if(d == 13) {return "K";}}int main() {int n;cin >> n;vector<int> d,c,h,s;rep(i,n) {string t;cin >> t;if(t[0] == 'D') {d.push_back(func(t[1]));} else if(t[0] == 'C') {c.push_back(func(t[1]));} else if(t[0] == 'H') {h.push_back(func(t[1]));} else if(t[0] == 'S') {s.push_back(func(t[1]));}}sort(d.begin(),d.end());sort(c.begin(),c.end());sort(h.begin(),h.end());sort(s.begin(),s.end());vector<string> v;rep(i,d.size()) v.push_back("D" + func2(d[i]));rep(i,c.size()) v.push_back("C" + func2(c[i]));rep(i,h.size()) v.push_back("H" + func2(h[i]));rep(i,s.size()) v.push_back("S" + func2(s[i]));rep(i,v.size()) {cout << v[i];if(i == v.size()-1) cout << endl;else cout << " ";}return 0;}