結果

問題 No.587 七対子
ユーザー kani_senbeikani_senbei
提出日時 2017-12-03 22:56:28
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 789 bytes
コンパイル時間 2,568 ms
コンパイル使用メモリ 77,452 KB
実行使用メモリ 55,988 KB
最終ジャッジ日時 2024-11-28 14:54:51
合計ジャッジ時間 7,903 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14 WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		HashMap<String, Integer> m = new HashMap<>();
		for (int i = 0; i < s.length(); i++) {
			String str = s.substring(i, i + 1);
			if (m.containsKey(str)) {
				m.put(str, m.get(str) + 1);
			} else {
				m.put(str, 1);
			}
		}
		boolean b = true;
		for (Map.Entry<String, Integer> entry : m.entrySet()) {
			if (entry.getValue().equals(new Integer(2))) {
				continue;
			} else if (entry.getValue().equals(new Integer(1))) {
				System.out.println(entry.getKey());
				b = false;
			}
		}
		if (b)
			System.out.println("Impossible");
	}
}
0