結果

問題 No.361 門松ゲーム2
ユーザー ぴろずぴろず
提出日時 2016-04-17 23:37:29
言語 Java21
(openjdk 21)
結果
AC  
実行時間 374 ms / 2,000 ms
コード長 903 bytes
コンパイル時間 1,903 ms
コンパイル使用メモリ 78,368 KB
実行使用メモリ 58,516 KB
最終ジャッジ日時 2024-04-15 02:31:02
合計ジャッジ時間 7,769 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
52,832 KB
testcase_01 AC 118 ms
53,812 KB
testcase_02 AC 127 ms
54,016 KB
testcase_03 AC 119 ms
53,740 KB
testcase_04 AC 117 ms
54,304 KB
testcase_05 AC 109 ms
52,988 KB
testcase_06 AC 119 ms
54,240 KB
testcase_07 AC 121 ms
53,968 KB
testcase_08 AC 137 ms
54,224 KB
testcase_09 AC 129 ms
54,028 KB
testcase_10 AC 124 ms
53,976 KB
testcase_11 AC 109 ms
53,056 KB
testcase_12 AC 128 ms
54,088 KB
testcase_13 AC 125 ms
53,656 KB
testcase_14 AC 272 ms
57,116 KB
testcase_15 AC 159 ms
53,720 KB
testcase_16 AC 250 ms
57,296 KB
testcase_17 AC 243 ms
54,844 KB
testcase_18 AC 186 ms
54,004 KB
testcase_19 AC 244 ms
55,152 KB
testcase_20 AC 155 ms
54,372 KB
testcase_21 AC 251 ms
57,008 KB
testcase_22 AC 374 ms
58,516 KB
testcase_23 AC 193 ms
54,520 KB
testcase_24 AC 223 ms
54,928 KB
testcase_25 AC 270 ms
54,752 KB
testcase_26 AC 295 ms
55,100 KB
testcase_27 AC 262 ms
54,892 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