結果

問題 No.267 トランプソート
ユーザー めうめう🎒めうめう🎒
提出日時 2016-02-15 00:09:35
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,257 bytes
コンパイル時間 857 ms
コンパイル使用メモリ 83,632 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 05:25:34
合計ジャッジ時間 1,809 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 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 1 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 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

string card[60];
int n;

map<char , int> change;

void srot_mark(){
	for(int i = 0;i < n-1;i++){
		for(int j = 0;j < n-1;j++){
			if(card[j+1][0] == 'D' && card[j][0] != 'D') swap(card[j],card[j+1]);
			else if(card[j][0] == 'S' && card[j+1][0] != 'S') swap(card[j],card[j+1]);
			else if(card[j][0] == 'H' && card[j+1][0] == 'C') swap(card[j],card[j+1]);
		}
	}
}

void srot_num(){
	for(int i = 0;i < n-1;i++){
		for(int j = 0;j < n-1;j++){
			int numa,numb;
			numa = change[card[j][1]];
			numb = change[card[j+1][1]];
			if(numa > numb && card[j][0] == card[j+1][0]){
				swap(card[j],card[j+1]);
			}
		}
	}
}

int main() {
	change['A'] = 1;
	change['T'] = 10;
	change['J'] = 11;
	change['Q'] = 12;
	change['K'] = 13;
	char num = '2';
	for(int i = 2;i <= 9;i++){
		change[num] = i;
		num++;
	}
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> card[i];
	}
	srot_mark();
	srot_num();
	for(int i = 0;i < n;i++) {
		cout << card[i] << " ";
	}
	cout << endl;
	return 0;
}
0