結果
| 問題 |
No.548 国士無双
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-02-18 20:18:10 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 117 ms / 2,000 ms |
| コード長 | 790 bytes |
| コンパイル時間 | 2,194 ms |
| コンパイル使用メモリ | 78,128 KB |
| 実行使用メモリ | 41,492 KB |
| 最終ジャッジ日時 | 2024-10-06 15:44:19 |
| 合計ジャッジ時間 | 5,764 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 |
ソースコード
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Scanner;
class Main {
public static void main(String[] args) throws Exception {
new Main().run();
}
void run() {
Scanner sc=new Scanner(System.in);
char[] cs=sc.next().toCharArray();
boolean find=false;
for(int i=0;i<26;++i) {
int[] cnt=new int[26];
for(int j=0;j<cs.length;++j)cnt[(int)(cs[j]-'a')]++;
cnt[i]++;
boolean flag=true;
for(int j=0;j<13;++j) {
flag&=cnt[j]>=1&&2>=cnt[j];
}
int c2=0;
for(int j=0;j<13;++j)if(cnt[j]==2)++c2;
flag&=c2==1;
if(flag) {
System.out.println((char)('a'+i));
find=true;
}
}
if(!find)System.out.println("Impossible");
}
static void tr(Object... objects) {
System.out.println(Arrays.deepToString(objects));
}
}