結果
| 問題 |
No.267 トランプソート
|
| コンテスト | |
| ユーザー |
jp_ste
|
| 提出日時 | 2016-05-11 16:01:02 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 167 ms / 1,000 ms |
| コード長 | 1,725 bytes |
| コンパイル時間 | 3,460 ms |
| コンパイル使用メモリ | 82,996 KB |
| 実行使用メモリ | 55,256 KB |
| 最終ジャッジ日時 | 2024-10-05 13:42:31 |
| 合計ジャッジ時間 | 7,856 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main2 {
public static void main(String[] args) {
try (Scanner scan = new Scanner(System.in)) {
int n = Integer.parseInt(scan.next());
ArrayList<String> list = new ArrayList<>();
for(int i=0; i<n; i++) {
char ch[] = scan.next().toCharArray();
if(ch[0] == 'D') ch[0] = '0';
else if(ch[0] == 'C') ch[0] = '1';
else if(ch[0] == 'H') ch[0] = '2';
else if(ch[0] == 'S') ch[0] = '3';
if(ch[1] == 'A') ch[1] = '1';
else if(ch[1] == 'T') ch[1] = 'A';
else if(ch[1] == 'J') ch[1] = 'B';
else if(ch[1] == 'Q') ch[1] = 'C';
else if(ch[1] == 'K') ch[1] = 'D';
list.add("" + ch[0] + ch[1]);
}
Collections.sort(list);
for(int i=0; i<list.size(); i++) {
if(i > 0) System.out.print(" ");
char f = list.get(i).charAt(0);
if(f == '0') f = 'D';
else if(f == '1') f = 'C';
else if(f == '2') f = 'H';
else if(f == '3') f = 'S';
char l = list.get(i).charAt(1);
if(l == '1') l = 'A';
else if(l == 'A') l = 'T';
else if(l == 'B') l = 'J';
else if(l == 'C') l = 'Q';
else if(l == 'D') l = 'K';
System.out.print("" + f + l);
}
}
}
}
jp_ste