結果

問題 No.548 国士無双
ユーザー YamaKasaYamaKasa
提出日時 2018-06-05 01:15:13
言語 Java19
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,305 bytes
コンパイル時間 2,839 ms
コンパイル使用メモリ 80,060 KB
実行使用メモリ 55,892 KB
最終ジャッジ日時 2023-09-19 08:46:07
合計ジャッジ時間 6,510 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,276 KB
testcase_01 AC 123 ms
55,664 KB
testcase_02 AC 123 ms
55,640 KB
testcase_03 AC 124 ms
55,516 KB
testcase_04 AC 125 ms
55,880 KB
testcase_05 AC 126 ms
55,832 KB
testcase_06 AC 127 ms
55,724 KB
testcase_07 AC 125 ms
55,604 KB
testcase_08 AC 124 ms
55,740 KB
testcase_09 AC 124 ms
55,276 KB
testcase_10 AC 124 ms
55,892 KB
testcase_11 AC 125 ms
55,608 KB
testcase_12 AC 124 ms
55,760 KB
testcase_13 AC 124 ms
55,624 KB
testcase_14 AC 124 ms
55,276 KB
testcase_15 AC 124 ms
55,292 KB
testcase_16 AC 124 ms
55,388 KB
testcase_17 AC 124 ms
55,648 KB
testcase_18 AC 124 ms
55,568 KB
testcase_19 AC 127 ms
55,332 KB
testcase_20 AC 130 ms
55,196 KB
testcase_21 AC 126 ms
55,880 KB
testcase_22 WA -
testcase_23 AC 125 ms
55,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String S = scan.next();
		scan.close();
		String []w1 = {"a", "b", "c", "d", "e", "f", "g", "h", "i",
				"j", "k", "l", "m"};
		String []w2 = {"n", "o", "p", "q", "r", "s", "t", "u", "v",
				"w", "x", "y", "z"};
		int l1 = w1.length;
		int []cnt1 = new int[l1];
		int []cnt2 = new int[l1];
		Arrays.fill(cnt1, 0);
		Arrays.fill(cnt2, 0);
		for(int i = 0; i < 13; i++) {
			String s = S.substring(i, i + 1);
			for(int j = 0; j < l1; j++) {
				if(s.equals(w1[j])) {
					cnt1[j] ++;
					break;
				}
				if(s.equals(w2[j])) {
					cnt2[j] ++;
					System.out.println("Impossible");
					System.exit(0);
				}
			}
		}
		Set<String> hash_set = new TreeSet<String>();
		int cnt3 = 0;
		for(int i = 0; i < 13; i++) {
			if(cnt1[i] > 1) {
				cnt3 ++;
			}
		}
		if(cnt3 >= 2) {
			System.out.println("Impossible");
			System.exit(0);
		}
		if(cnt3 == 0) {
			for(int i = 0; i < 13; i++) {
				System.out.println(w1[i]);
			}
			System.exit(0);
		}
		for(int i = 0; i < 13; i++) {
			if(cnt1[i] == 0) {
				hash_set.add(w1[i]);
			}
		}
		for(String t : hash_set) {
			System.out.println(t);
		}

	}
}
0