結果

問題 No.587 七対子
ユーザー tenten
提出日時 2020-11-04 11:40:53
言語 Java
(openjdk 23)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 591 bytes
コンパイル時間 2,072 ms
コンパイル使用メモリ 74,916 KB
実行使用メモリ 41,388 KB
最終ジャッジ日時 2024-07-22 09:54:43
合計ジャッジ時間 7,920 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[] counts = new int[26];
		for (char c : sc.next().toCharArray()) {
		    counts[c - 'a']++;
		}
		char x = '0';
		for (int i = 0; i < counts.length; i++) {
		    if (counts[i] == 2 || counts[i] == 0) {
		        continue;
		    } else {
		        if (counts[i] == 1 && x == '0') {
		            x = (char)(i + 'a');
		        } else {
		            System.out.println("Impossible");
		            return;
		        }
		    }
		}
		System.out.println(x);
	}
}
0