結果

問題 No.267 トランプソート
ユーザー fmhrfmhr
提出日時 2016-07-09 06:21:45
言語 Go
(1.21.3)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,285 bytes
コンパイル時間 12,312 ms
コンパイル使用メモリ 212,156 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-03 11:26:32
合計ジャッジ時間 11,760 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,384 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	m := make([]string, n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)
		switch s[0] {
		case 'D':
			s = replaceAtIndex(s, 0, 'A')
		case 'C':
			s = replaceAtIndex(s, 0, 'B')
		case 'H':
			s = replaceAtIndex(s, 0, 'C')
		case 'S':
			s = replaceAtIndex(s, 0, 'D')
		}
		switch s[1] {
		case 'A':
			s = replaceAtIndex(s, 1, '1')
		case 'T':
			s = replaceAtIndex(s, 1, 'a')
		case 'J':
			s = replaceAtIndex(s, 1, 'b')
		case 'Q':
			s = replaceAtIndex(s, 1, 'c')
		case 'K':
			s = replaceAtIndex(s, 1, 'd')
		}
		m[i] = s
	}
	sort.Strings(m)
	for i, s := range m {
		switch s[0] {
		case 'A':
			s = replaceAtIndex(s, 0, 'D')
		case 'B':
			s = replaceAtIndex(s, 0, 'C')
		case 'C':
			s = replaceAtIndex(s, 0, 'H')
		case 'D':
			s = replaceAtIndex(s, 0, 'S')
		}
		switch s[1] {
		case '1':
			s = replaceAtIndex(s, 1, 'A')
		case 'a':
			s = replaceAtIndex(s, 1, 'T')
		case 'b':
			s = replaceAtIndex(s, 1, 'J')
		case 'c':
			s = replaceAtIndex(s, 1, 'Q')
		case 'd':
			s = replaceAtIndex(s, 1, 'K')
		}
		fmt.Print(s)
		if i!=len(m)-1{
			fmt.Print(" ")
		}
	}
	fmt.Println("")
}

func replaceAtIndex(s string, index int, r rune) string{
	return s[:index] + string(r) + s[index+1:]
}
0