結果

問題 No.267 トランプソート
ユーザー Yang33Yang33
提出日時 2018-08-31 16:24:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 2,327 bytes
コンパイル時間 1,812 ms
コンパイル使用メモリ 174,776 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-11 22:50:13
合計ジャッジ時間 2,945 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,352 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 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,352 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,352 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,352 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: ラムダ関数内:
main.cpp:64:9: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type]
   64 |         };
      |         ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>; using PLL = pair < LL, LL >;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/08/31  Problem: yukicoder267 / Link: https://yukicoder.me/problems/no/267  ----- */
/* ------問題------

友達とトランプで遊ぶことにしました。
カードを配ってもらいましたが、手札のカードを順番に並べないと気が済みません。
カードを順番通りに並び替えてください。

カードは左から順にダイヤ、クローバー、ハート、スペードの順に並べます。
マークごとに左から順に数字の小さい順に並べます。

-----問題ここまで----- */
/* -----解説等-----


----解説ここまで---- */

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	int N; cin >> N;
	VS vs(N);
	FOR(i, 0, N) {
		cin >> vs[i];
	}
	auto decode = [](char c) {
		if (isdigit(c))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;

			else if (c == 'D')return 0;
			else if (c == 'C')return 1;
			else if (c == 'H')return 2;
			else if (c == 'S')return 3;
		}
	};


	sort(ALL(vs), [&](const string &a, const string &b) {
		if (decode(a[0]) == decode(b[0])) {
			return decode(a[1]) <= decode(b[1]);
		}
		else {
			return decode(a[0]) <= decode(b[0]);
		}
	});

	FOR(i, 0, N) {
		cout << vs[i] << " \n"[i == N - 1];
	}

	return 0;
}
0