結果

問題 No.548 国士無双
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-10 23:29:48
言語 Java19
(openjdk 21)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 963 bytes
コンパイル時間 2,126 ms
コンパイル使用メモリ 77,492 KB
実行使用メモリ 57,704 KB
最終ジャッジ日時 2023-10-17 17:21:40
合計ジャッジ時間 6,133 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
57,476 KB
testcase_01 AC 125 ms
57,504 KB
testcase_02 AC 125 ms
57,520 KB
testcase_03 AC 125 ms
57,480 KB
testcase_04 AC 125 ms
57,428 KB
testcase_05 AC 125 ms
57,168 KB
testcase_06 AC 125 ms
57,536 KB
testcase_07 AC 124 ms
57,452 KB
testcase_08 AC 121 ms
57,424 KB
testcase_09 AC 124 ms
57,340 KB
testcase_10 AC 125 ms
57,360 KB
testcase_11 AC 123 ms
57,416 KB
testcase_12 AC 124 ms
57,444 KB
testcase_13 AC 125 ms
57,424 KB
testcase_14 AC 126 ms
57,400 KB
testcase_15 AC 125 ms
57,364 KB
testcase_16 AC 124 ms
57,560 KB
testcase_17 AC 125 ms
57,648 KB
testcase_18 AC 126 ms
57,540 KB
testcase_19 AC 125 ms
57,536 KB
testcase_20 AC 125 ms
57,552 KB
testcase_21 AC 126 ms
57,704 KB
testcase_22 AC 123 ms
57,628 KB
testcase_23 AC 123 ms
55,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int[] ar = new int[13];
		String s = sc.next();
		for (int i=0; i<13; i++) {
			char c = s.charAt(i);
			if (c>=97 && c<=109) {ar[c-97]++;}
		}
		
		//可能なパターン
		//・0が1個、1が11個、2が1個のとき(0の文字を出力)
		//・1が13個(全種辞書順に出力)
		//それ以外の場合
		//・3が1個混じっているなど(Impossibleを出力)
		
		int zero = 0;
		int zero_num = 0;
		int one = 0;
		int two = 0;
		
		for (int i=0; i<13; i++) {
			if (ar[i]==0) {
				zero++;
				zero_num = i;
			}
			else if (ar[i]==1) {one++;}
			else if (ar[i]==2) {two++;}
		}
		
		if (zero==1 && one==11 && two==1) {System.out.println((char)(zero_num+97));}
		else if (one==13) {
			for (int i=0; i<13; i++) {
				System.out.println((char)(i+97));
			}
		}
		else {System.out.println("Impossible");}
	}
}
0