結果

問題 No.267 トランプソート
ユーザー uafr_csuafr_cs
提出日時 2015-08-21 22:28:10
言語 Java19
(openjdk 21)
結果
AC  
実行時間 174 ms / 1,000 ms
コード長 1,459 bytes
コンパイル時間 4,441 ms
コンパイル使用メモリ 83,804 KB
実行使用メモリ 57,140 KB
最終ジャッジ日時 2023-09-25 14:40:27
合計ジャッジ時間 9,832 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 159 ms
57,024 KB
testcase_01 AC 162 ms
56,656 KB
testcase_02 AC 163 ms
56,632 KB
testcase_03 AC 163 ms
56,616 KB
testcase_04 AC 163 ms
56,612 KB
testcase_05 AC 159 ms
56,928 KB
testcase_06 AC 160 ms
56,768 KB
testcase_07 AC 164 ms
56,420 KB
testcase_08 AC 174 ms
56,864 KB
testcase_09 AC 170 ms
56,872 KB
testcase_10 AC 171 ms
56,992 KB
testcase_11 AC 168 ms
56,764 KB
testcase_12 AC 169 ms
56,580 KB
testcase_13 AC 172 ms
56,888 KB
testcase_14 AC 167 ms
56,952 KB
testcase_15 AC 169 ms
57,140 KB
testcase_16 AC 170 ms
56,676 KB
testcase_17 AC 173 ms
56,740 KB
testcase_18 AC 172 ms
56,968 KB
testcase_19 AC 174 ms
56,672 KB
testcase_20 AC 171 ms
56,844 KB
testcase_21 AC 171 ms
57,016 KB
testcase_22 AC 173 ms
56,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Set;

public class Main {
	
	public static class Card implements Comparable<Card> {
		char soot_ch, num_ch;
		int soot, num;

		public Card(char[] card) {
			this.soot_ch = card[0];
			this.num_ch = card[1];
			
			switch(this.soot_ch){
			case 'D': soot = 0; break;
			case 'C': soot = 1; break;
			case 'H': soot = 2; break;
			case 'S': soot = 3; break;
			}
			
			switch(this.num_ch){
			case 'A': num = 1; break;
			case 'T': num = 10; break;
			case 'J': num = 11; break;
			case 'Q': num = 12; break;
			case 'K': num = 13; break;
			default: num = Character.getNumericValue(num_ch);
			}
		}

		@Override
		public int compareTo(Card o) {
			if(Integer.compare(this.soot, o.soot) != 0){
				return Integer.compare(this.soot, o.soot);
			}else{
				return Integer.compare(this.num, o.num);
			}
		}
		
		@Override
		public String toString(){
			return this.soot_ch + "" + this.num_ch;
		}
		
		
	}
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		Card[] cards = new Card[N];
		for(int i = 0; i < N; i++){
			cards[i] = new Card(sc.next().toCharArray());
		}
		
		Arrays.sort(cards);
		for(int i = 0; i < N; i++){
			System.out.print((i != 0 ? " " : "") + cards[i]);
		}
		System.out.println();
		
	}
	
}
0