結果

問題 No.267 トランプソート
ユーザー MayimgMayimg
提出日時 2019-01-04 05:24:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 770 bytes
コンパイル時間 1,756 ms
コンパイル使用メモリ 172,636 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-03 02:38:08
合計ジャッジ時間 2,597 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'bool comp(std::pair<char, char>, std::pair<char, char>)':
main.cpp:16:21: warning: 'yy' may be used uninitialized [-Wmaybe-uninitialized]
   16 |         return xx < yy;
      |                     ^~
main.cpp:4:17: note: 'yy' was declared here
    4 |         int xx, yy;
      |                 ^~
main.cpp:16:21: warning: 'xx' may be used uninitialized [-Wmaybe-uninitialized]
   16 |         return xx < yy;
      |                     ^~
main.cpp:4:13: note: 'xx' was declared here
    4 |         int xx, yy;
      |             ^~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
bool comp(const pair<char, char> x, const pair<char, char> y) {
	int xx, yy;
	string t = "DCHS", u = "A23456789TJQK";
	for(int i = 0; i < 4; i++) {
		if(x.first == t[i]) xx = i;
		if(y.first == t[i]) yy = i;
	}
	xx *= 10;
	yy *= 10;
	for(int i = 0; i < u.size(); i++) {
		if(x.second == u[i]) xx += i;
		if(y.second == u[i]) yy += i;
	}
	return xx < yy;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);  
	
	int n;
	cin >> n;
	vector<pair<char, char>> a(n);
	for(int i = 0; i < n; i++) {
		string s;
		cin >> s;
		a[i].first = s[0];
		a[i].second = s[1];
	}
	sort(a.begin(), a.end(), comp);
	for(int i = 0; i < n; i++) {
		if(i > 0) cout << " ";
		cout << a[i].first << a[i].second;
	}
	cout << '\n';
	return 0;	
}
0