結果

問題 No.267 トランプソート
ユーザー MayimgMayimg
提出日時 2019-01-04 05:38:56
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 659 bytes
コンパイル時間 1,870 ms
コンパイル使用メモリ 175,304 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-15 15:19:43
合計ジャッジ時間 2,796 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘bool comp(std::string, std::string)’ 内:
main.cpp:11:24: 警告: ‘yy’ may be used uninitialized [-Wmaybe-uninitialized]
   11 |         xx *= 1000; yy *= 1000;
      |                     ~~~^~~~~~~
main.cpp:6:17: 備考: ‘yy’ はここで定義されています
    6 |         int xx, yy;
      |                 ^~
main.cpp:11:12: 警告: ‘xx’ may be used uninitialized [-Wmaybe-uninitialized]
   11 |         xx *= 1000; yy *= 1000;
      |         ~~~^~~~~~~
main.cpp:6:13: 備考: ‘xx’ はここで定義されています
    6 |         int xx, yy;
      |             ^~

ソースコード

diff #

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

bool comp(string x, string y) {
	string a = "DCHS", b = "A23456789TJQK";
	int xx, yy;
	for(int i = 0; i < a.size(); i++) {
		if(x[0] == a[i]) xx = i + 1;
		if(y[0] == a[i]) yy = i + 1;
	}
	xx *= 1000; yy *= 1000;
	for(int i = 0; i < b.size(); i++) {
		if(x[1] == b[i]) xx += i;
		if(y[1] == b[i]) yy += i;
	}
	return xx < yy;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);  
	
	int n;
	cin >> n;
	vector<string> s(n);
	for(int i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s.begin(), s.end(), comp);
	for(int i = 0; i < n; i++) {
		if(i > 0) cout << " ";
		cout << s[i];
	}
	cout << endl;
	return 0;	
}
0