結果

問題 No.267 トランプソート
ユーザー kenji_shioyakenji_shioya
提出日時 2016-06-16 02:15:21
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,928 bytes
コンパイル時間 3,512 ms
コンパイル使用メモリ 83,716 KB
実行使用メモリ 55,320 KB
最終ジャッジ日時 2024-04-17 22:49:33
合計ジャッジ時間 7,336 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 141 ms
54,908 KB
testcase_01 AC 130 ms
55,072 KB
testcase_02 AC 131 ms
54,492 KB
testcase_03 AC 137 ms
55,016 KB
testcase_04 AC 129 ms
55,008 KB
testcase_05 AC 129 ms
54,764 KB
testcase_06 AC 120 ms
54,652 KB
testcase_07 AC 134 ms
55,144 KB
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 #

import java.util.*;

public class Exercise86{
  public static void main (String[] args){

    Scanner sc = new Scanner(System.in);

    ArrayList<ArrayList<String>> array = new ArrayList<ArrayList<String>>();
    for(int i = 0; i < 4; i++){
      array.add(new ArrayList<String>());
    }
    int n = sc.nextInt();
    for(int i = 0; i < n; i++){
      String x = sc.next();
      if(x.contains("D")){
        x = changeNum(x);
        array.get(0).add(x);
      }else if(x.contains("C")){
        x = changeNum(x);
        array.get(1).add(x);
      }else if(x.contains("H")){
        x = changeNum(x);
        array.get(2).add(x);
      }else if(x.contains("S")){
        x = changeNum(x);
        array.get(3).add(x);
      }
    }
    for(int i = 0; i < array.size(); i++){
      Collections.sort(array.get(i));
    }
    String answer = "";

    for(int i = 0; i < array.size(); i++){
      for(int j = 0; j < array.get(i).size(); j++){
        String y = changeNum(array.get(i).get(j));
        answer += y + " ";
      }
    }
    System.out.println(answer);

  }
  private static String changeNum(String x){
    if (x.contains("T")){
      x = x.replace("T", "10");
      return x;
    }else if(x.contains("J")){
      x = x.replace("J", "11");
      return x;
    }else if(x.contains("Q")){
      x = x.replace("Q", "12");
      return x;
    }else if(x.contains("K")){
      x = x.replace("K", "13");
      return x;
    }else if(x.contains("A")){
      x = x.replace("A", "1");
      return x;
    }else if(x.contains("10")){
      x = x.replace("10", "T");
      return x;
    }else if(x.contains("11")){
      x = x.replace("11", "J");
      return x;
    }else if(x.contains("12")){
      x = x.replace("12", "Q");
      return x;
    }else if(x.contains("13")){
      x = x.replace("13", "K");
      return x;
    }else if(x.contains("1")){
      x = x.replace("1", "A");
      return x;
    }
    return x;
  }
}
0