結果

問題 No.267 トランプソート
ユーザー fmhrfmhr
提出日時 2016-07-09 06:20:08
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 1,286 bytes
コンパイル時間 10,916 ms
コンパイル使用メモリ 216,500 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 09:18:19
合計ジャッジ時間 11,686 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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)
	fmt.Println(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')
		}
		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