結果

問題 No.267 トランプソート
ユーザー matsukin1111matsukin1111
提出日時 2019-04-14 21:53:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,812 bytes
コンパイル時間 1,055 ms
コンパイル使用メモリ 102,300 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 20:51:35
合計ジャッジ時間 2,115 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };

int check(char c) {
	if (2 <= c - '0' && c - '0' <= 9)return c - '0';

	switch (c) {
	case 'A':
		return 1;
	case 'T':
		return 10;
	case 'J':
		return 11;
	case 'Q':
		return 12;
	case 'K':
		return 13;
	}
}

string conv(int i) {
	if (2 <= i && i <= 9)return to_string(i);
	switch (i) {
	case 1 :
		return "A";
	case 10:
		return "T";
	case 11 :
		return "J";
	case 12 :
		return "Q";
	case 13:
		return "K";
	}
}

int main() {
	int n;
	cin >> n;

	vector<int>D;
	vector<int>C;
	vector<int>H;
	vector<int>S;

	rep(i, 0, n) {
		string s;
		cin >> s;
		char temp = s[0];
		int num = check(s[1]);

		switch (temp) {
		case 'D':
			D.pb(num);
			break;
		case 'C':
			C.pb(num);
			break;
		case 'H':
			H.pb(num);
			break;
		case 'S':
			S.pb(num);
			break;
		}
	}
	sort(all(D));
	sort(all(C));
	sort(all(H));
	sort(all(S));

	fore(i, D) {
		cout << 'D' << conv(i) << " ";
	}
	fore(i, C) {
		cout << 'C' << conv(i) << " ";
	}
	fore(i, H) {
		cout << 'H' << conv(i) << " ";
	}
	fore(i, S) {
		cout << 'S' << conv(i) << " ";
	}
	cout << endl;
	
	
	return 0;
}
0