結果

問題 No.621 3 x N グリッド上のドミノの置き方の数
ユーザー tailstails
提出日時 2017-12-21 12:19:28
言語 cLay
(20240104-1)
結果
AC  
実行時間 82 ms / 3,000 ms
コード長 895 bytes
コンパイル時間 2,977 ms
コンパイル使用メモリ 178,860 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-18 23:50:31
合計ジャッジ時間 9,081 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,380 KB
testcase_01 AC 6 ms
4,380 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 3 ms
4,384 KB
testcase_04 AC 4 ms
4,384 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 5 ms
4,376 KB
testcase_07 AC 5 ms
4,376 KB
testcase_08 AC 6 ms
4,380 KB
testcase_09 AC 5 ms
4,380 KB
testcase_10 AC 5 ms
4,380 KB
testcase_11 AC 6 ms
4,380 KB
testcase_12 AC 9 ms
4,376 KB
testcase_13 AC 10 ms
4,380 KB
testcase_14 AC 16 ms
4,376 KB
testcase_15 AC 20 ms
4,376 KB
testcase_16 AC 23 ms
4,376 KB
testcase_17 AC 24 ms
4,376 KB
testcase_18 AC 30 ms
4,380 KB
testcase_19 AC 31 ms
4,376 KB
testcase_20 AC 35 ms
4,380 KB
testcase_21 AC 37 ms
4,380 KB
testcase_22 AC 43 ms
4,380 KB
testcase_23 AC 44 ms
4,376 KB
testcase_24 AC 47 ms
4,380 KB
testcase_25 AC 54 ms
4,376 KB
testcase_26 AC 54 ms
4,376 KB
testcase_27 AC 61 ms
4,376 KB
testcase_28 AC 61 ms
4,376 KB
testcase_29 AC 66 ms
4,384 KB
testcase_30 AC 63 ms
4,376 KB
testcase_31 AC 60 ms
4,380 KB
testcase_32 AC 57 ms
4,380 KB
testcase_33 AC 66 ms
4,376 KB
testcase_34 AC 63 ms
4,380 KB
testcase_35 AC 60 ms
4,376 KB
testcase_36 AC 62 ms
4,380 KB
testcase_37 AC 67 ms
4,380 KB
testcase_38 AC 69 ms
4,376 KB
testcase_39 AC 70 ms
4,380 KB
testcase_40 AC 70 ms
4,376 KB
testcase_41 AC 70 ms
4,380 KB
testcase_42 AC 68 ms
4,380 KB
testcase_43 AC 69 ms
4,376 KB
testcase_44 AC 69 ms
4,376 KB
testcase_45 AC 70 ms
4,376 KB
testcase_46 AC 69 ms
4,380 KB
testcase_47 AC 69 ms
4,380 KB
testcase_48 AC 70 ms
4,380 KB
testcase_49 AC 70 ms
4,376 KB
testcase_50 AC 69 ms
4,376 KB
testcase_51 AC 70 ms
4,380 KB
testcase_52 AC 69 ms
4,376 KB
testcase_53 AC 71 ms
4,380 KB
testcase_54 AC 70 ms
4,380 KB
testcase_55 AC 71 ms
4,380 KB
testcase_56 AC 70 ms
4,380 KB
testcase_57 AC 71 ms
4,376 KB
testcase_58 AC 60 ms
4,380 KB
testcase_59 AC 81 ms
4,380 KB
testcase_60 AC 82 ms
4,376 KB
testcase_61 AC 82 ms
4,380 KB
testcase_62 AC 82 ms
4,380 KB
testcase_63 AC 43 ms
4,380 KB
testcase_64 AC 44 ms
4,380 KB
testcase_65 AC 44 ms
4,380 KB
testcase_66 AC 45 ms
4,380 KB
testcase_67 AC 44 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

struct M {
	mint a[64][64];
	void zero(){
		a[0...63][0..63]=0;
	}
	void unit(){
		zero();
		a[0..63][0..63]=1;
	}
	mint* operator[](int y){
		return a[y];
	}
};

M operator*(M&a,M&b){
	M c;
	rep(y,64){
		rep(x,64){
			c[y][x]=0;
			rep(z,64){
				c[y][x]+=a[z][x]*b[y][z];
			}
		}
	}
	return c;	
}

bool ok(int k){
	return k&3 && k&6 && k&030 && k&060 && k&011 && k&022 && k&044;
}
void dbg_p(M&a){
	rep(y,64){
		wt(y/8*10+y%8,": ",a.a[y](64),ok(y)?"*":"");
	}
}

{
	ll n;
	M a,e;

	a.zero();
	rep(i,64){
		rep(j1,8){int j=j1*9;
			if((i<<3&j)==0){
				int k=i<<3|j;
				if(ok(k/8)){
					a[k&077][i]+=1;
				}
			}
		}
	}
	rep(i,64){
		rep(j,64){
			if((j&3)==0){
				a[j|3][i]+=a[j][i];
			}
			if((j&6)==0){
				a[j|6][i]+=a[j][i];
			}
		}
	}

	rd(n);
	e.unit();
	while(n){
		if(n&1){
			e=e*a;
		}
		a=a*a;
		n>>=1;
	}
	mint c=0;
	rep(k,64){
		if(ok(k)){
			c+=e[k][63];
		}
	}
	wt(c);
}
0