結果

問題 No.361 門松ゲーム2
ユーザー ぴろずぴろず
提出日時 2016-04-17 23:16:50
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 813 bytes
コンパイル時間 1,946 ms
コンパイル使用メモリ 78,176 KB
実行使用メモリ 58,360 KB
最終ジャッジ日時 2024-04-15 02:26:27
合計ジャッジ時間 6,924 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
53,140 KB
testcase_01 AC 107 ms
53,064 KB
testcase_02 AC 111 ms
53,608 KB
testcase_03 AC 116 ms
54,040 KB
testcase_04 AC 108 ms
53,120 KB
testcase_05 AC 108 ms
53,132 KB
testcase_06 WA -
testcase_07 AC 108 ms
53,880 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 110 ms
54,452 KB
testcase_12 AC 112 ms
52,992 KB
testcase_13 AC 111 ms
53,140 KB
testcase_14 AC 249 ms
57,084 KB
testcase_15 WA -
testcase_16 AC 181 ms
54,644 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 156 ms
54,452 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 321 ms
58,360 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 139 ms
54,024 KB
testcase_26 WA -
testcase_27 AC 163 ms
54,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no361;

import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		int d = sc.nextInt();
		System.out.println(kadoWins(l, d) ? "kado" : "matsu");
	}
	
	public static boolean kadoWins(int l,int d) {
		int[] grundy = new int[l+1];
		for(int i=1;i<=l;i++) {
			HashSet<Integer> hs = new HashSet<>();
			for(int l1=1;l1<=i;l1++) {
				for(int l2=l1+1;l2<=i;l2++) {
					int l3 = i - l1 - l2;
					if (l3 <= l2 || l3 - l1 > d) {
						break;
					}
					hs.add(grundy[l1] ^ grundy[l2] ^ grundy[l3]);
				}
			}
			for(int g=0;;g++) {
				if (!hs.contains(g)) {
					grundy[i] = g;
					break;
				}
			}
		}
//		System.out.println(Arrays.toString(grundy));
		return grundy[l] != 0;
	}

}
0