結果

問題 No.361 門松ゲーム2
ユーザー ぴろずぴろず
提出日時 2016-04-17 23:37:29
言語 Java19
(openjdk 21)
結果
AC  
実行時間 419 ms / 2,000 ms
コード長 903 bytes
コンパイル時間 2,207 ms
コンパイル使用メモリ 75,480 KB
実行使用メモリ 60,052 KB
最終ジャッジ日時 2023-07-27 14:54:35
合計ジャッジ時間 8,661 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,296 KB
testcase_01 AC 126 ms
55,604 KB
testcase_02 AC 122 ms
55,900 KB
testcase_03 AC 122 ms
55,984 KB
testcase_04 AC 121 ms
55,556 KB
testcase_05 AC 122 ms
55,620 KB
testcase_06 AC 121 ms
55,764 KB
testcase_07 AC 124 ms
55,764 KB
testcase_08 AC 140 ms
57,124 KB
testcase_09 AC 159 ms
56,196 KB
testcase_10 AC 128 ms
55,512 KB
testcase_11 AC 126 ms
55,828 KB
testcase_12 AC 144 ms
55,880 KB
testcase_13 AC 145 ms
55,632 KB
testcase_14 AC 283 ms
58,732 KB
testcase_15 AC 179 ms
56,116 KB
testcase_16 AC 264 ms
58,900 KB
testcase_17 AC 241 ms
56,700 KB
testcase_18 AC 192 ms
55,944 KB
testcase_19 AC 246 ms
56,544 KB
testcase_20 AC 157 ms
55,560 KB
testcase_21 AC 255 ms
58,424 KB
testcase_22 AC 419 ms
60,052 KB
testcase_23 AC 191 ms
55,848 KB
testcase_24 AC 183 ms
56,640 KB
testcase_25 AC 263 ms
56,160 KB
testcase_26 AC 265 ms
56,280 KB
testcase_27 AC 268 ms
57,008 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++) {
//			System.out.println(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) {
						continue;
					}
//					System.out.println(l1 + "," + l2 + "," + l3);
					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