結果

問題 No.361 門松ゲーム2
ユーザー 37zigen37zigen
提出日時 2016-05-28 11:07:57
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,016 bytes
コンパイル時間 2,145 ms
コンパイル使用メモリ 77,408 KB
実行使用メモリ 41,816 KB
最終ジャッジ日時 2024-04-16 18:04:54
合計ジャッジ時間 7,041 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
41,552 KB
testcase_01 AC 130 ms
41,392 KB
testcase_02 AC 129 ms
41,472 KB
testcase_03 AC 129 ms
41,564 KB
testcase_04 AC 129 ms
41,680 KB
testcase_05 AC 129 ms
41,576 KB
testcase_06 AC 121 ms
40,320 KB
testcase_07 AC 132 ms
41,628 KB
testcase_08 AC 133 ms
41,260 KB
testcase_09 AC 130 ms
41,348 KB
testcase_10 AC 130 ms
41,040 KB
testcase_11 AC 132 ms
41,440 KB
testcase_12 AC 131 ms
41,816 KB
testcase_13 WA -
testcase_14 AC 130 ms
41,320 KB
testcase_15 AC 141 ms
41,432 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 154 ms
40,744 KB
testcase_20 AC 135 ms
41,120 KB
testcase_21 AC 147 ms
41,808 KB
testcase_22 AC 131 ms
41,220 KB
testcase_23 AC 144 ms
40,432 KB
testcase_24 WA -
testcase_25 AC 166 ms
41,568 KB
testcase_26 WA -
testcase_27 AC 154 ms
41,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		new Main().solve();
	}
	void solve(){
		Scanner sc=new Scanner(System.in);
		int L=sc.nextInt();
		int D=sc.nextInt();
		boolean[] g=new boolean[L+1];
		//g[i]=長さiの竹のみがあるとき、勝つことができるか。

		for(int len=1;len<=L;len++){
			out:for(int i=1;3*i<=len;i++){
				for(int j=i+1;i+2*j<len;j++){
					//k>j,len-i-j>j,len-i>2*j,i+2*j<len
					int k=len-i-j;
					if(isKadomatsu(i,j,k,D)){
						if((!g[i])^(!g[j])^(!g[k])){
							g[len]=true;
							break out;
						}
					}
				}
			}
		}
		System.out.println(g[L]?"kado":"matsu");
	}
	void tr(Object...o){
		System.out.println(Arrays.deepToString(o));
	}
	//x,y,zは昇順にソートされているとする。
	boolean isKadomatsu(int x,int y,int z,int D){
		if(z-x>D)return false;
		if(x==y||y==z||z==x){
			return false;
		}else if(x<y&&y<z){
			return true;
		}else {
			return false;
		}
	}
}
0