結果

問題 No.548 国士無双
ユーザー tsunabittsunabit
提出日時 2019-06-17 22:27:50
言語 Java21
(openjdk 21)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 1,097 bytes
コンパイル時間 4,283 ms
コンパイル使用メモリ 74,848 KB
実行使用メモリ 56,504 KB
最終ジャッジ日時 2023-08-19 10:56:10
合計ジャッジ時間 8,814 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
55,968 KB
testcase_01 AC 105 ms
55,880 KB
testcase_02 AC 103 ms
55,592 KB
testcase_03 AC 104 ms
55,476 KB
testcase_04 AC 106 ms
56,504 KB
testcase_05 AC 104 ms
55,792 KB
testcase_06 AC 101 ms
55,952 KB
testcase_07 AC 102 ms
55,984 KB
testcase_08 AC 105 ms
55,540 KB
testcase_09 AC 107 ms
56,160 KB
testcase_10 AC 101 ms
55,796 KB
testcase_11 AC 109 ms
55,916 KB
testcase_12 AC 109 ms
55,680 KB
testcase_13 AC 104 ms
55,712 KB
testcase_14 AC 103 ms
55,864 KB
testcase_15 AC 105 ms
55,616 KB
testcase_16 AC 106 ms
55,824 KB
testcase_17 AC 105 ms
56,060 KB
testcase_18 AC 102 ms
55,360 KB
testcase_19 AC 104 ms
55,880 KB
testcase_20 AC 104 ms
55,700 KB
testcase_21 AC 108 ms
55,652 KB
testcase_22 AC 107 ms
55,808 KB
testcase_23 AC 103 ms
56,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.math.*;

public class No548 {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String s = sc.next();
    	HashMap<Character, Integer> hm = new HashMap<Character, Integer>();
    	
    	for(int i = 0; i < s.length(); i++) {
    		if(hm.containsKey(s.charAt(i))) {
    			hm.put(s.charAt(i), hm.get(s.charAt(i)) + 1);
    		}else {
    			hm.put(s.charAt(i), 1);
    		}
    	}
    	int max = 0, min = 13, c = 0;
    	for (char k : hm.keySet()) {
    		if(2 < hm.get(k)) {
    			System.out.println("Impossible");
    			return;
    		}else if(hm.get(k) == 2) {
    			c++;
    		}
    	}
    	if(c > 1) {
    		System.out.println("Impossible");
    	}else {
    		char[] moji = {'a','b','c','d','e','f','g','h','i','j','k','l','m'};
    		if(c == 1) {
    			for(int i = 0; i < 13; i++) {
    				if(!hm.containsKey(moji[i])) {
    					System.out.println(moji[i]);
    				}
    			}
    		}else {
    			for(int i = 0; i < 13; i++) {
    				System.out.println(moji[i]);
    			}
    		}
    	}
    }
}
0