結果

問題 No.548 国士無双
ユーザー tsunabit
提出日時 2019-06-17 22:27:50
言語 Java
(openjdk 23)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 1,097 bytes
コンパイル時間 3,127 ms
コンパイル使用メモリ 77,848 KB
実行使用メモリ 41,248 KB
最終ジャッジ日時 2024-11-29 02:44:15
合計ジャッジ時間 6,696 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

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