結果

問題 No.267 トランプソート
ユーザー ry0u_ydry0u_yd
提出日時 2015-09-06 23:24:36
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,900 bytes
コンパイル時間 1,078 ms
コンパイル使用メモリ 81,324 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-26 09:50:04
合計ジャッジ時間 2,073 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int func(char)’:
main.cpp:34:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
main.cpp: In function ‘std::__cxx11::string func2(int)’:
main.cpp:52:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^

ソースコード

diff #

#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_pair

using 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;
}
0