結果

問題 No.267 トランプソート
ユーザー fmhr
提出日時 2016-07-09 06:21:45
言語 Go
(1.23.4)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,285 bytes
コンパイル時間 11,908 ms
コンパイル使用メモリ 224,624 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-13 08:11:27
合計ジャッジ時間 11,689 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

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:]
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0