結果

問題 No.632 穴埋め門松列
ユーザー jimanojimano
提出日時 2018-01-23 22:51:01
言語 Java21
(openjdk 21)
結果
AC  
実行時間 52 ms / 1,000 ms
コード長 1,023 bytes
コンパイル時間 3,384 ms
コンパイル使用メモリ 75,132 KB
実行使用メモリ 34,080 KB
最終ジャッジ日時 2023-08-26 23:56:10
合計ジャッジ時間 4,295 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
33,704 KB
testcase_01 AC 38 ms
33,540 KB
testcase_02 AC 45 ms
33,928 KB
testcase_03 AC 48 ms
34,080 KB
testcase_04 AC 39 ms
33,208 KB
testcase_05 AC 47 ms
34,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package me.yukicoder.lv1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class No0632 {
	public static void main(String[] args) {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String[] str = br.readLine().split(" ");
			int[] matsu = new int[str.length];
			int hatena = 0;
			String ans = null;

			for (int i = 0; i < 3; i++) {
				if (str[i].equals("?")) {
					hatena = i;
					matsu[i] = 0;
				} else {
					matsu[i] = Integer.parseInt(str[i]);
				}
			}

			matsu[hatena] = 1;
			ans = isKadomatsu(matsu) ? "1" : "";
			matsu[hatena] = 4;
			ans = isKadomatsu(matsu) ? ans + "4" : ans;

			System.out.println(ans);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	static boolean isKadomatsu(int[] matsu) {
		int[] tmp = { matsu[0], matsu[1], matsu[2] };
		Arrays.sort(tmp);
		return (tmp[1] != matsu[1]) && (matsu[0] != matsu[1] && matsu[1] != matsu[2] && matsu[0] != matsu[2]);
	}
}
0