結果

問題 No.621 3 x N グリッド上のドミノの置き方の数
ユーザー WA_TLEWA_TLE
提出日時 2017-12-21 00:32:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 3,000 ms
コード長 2,573 bytes
コンパイル時間 1,231 ms
コンパイル使用メモリ 130,736 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-22 11:07:46
合計ジャッジ時間 3,664 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,376 KB
testcase_01 AC 4 ms
4,376 KB
testcase_02 AC 4 ms
4,376 KB
testcase_03 AC 4 ms
4,376 KB
testcase_04 AC 4 ms
4,376 KB
testcase_05 AC 4 ms
4,376 KB
testcase_06 AC 4 ms
4,380 KB
testcase_07 AC 4 ms
4,380 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 4 ms
4,376 KB
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 4 ms
4,380 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 4 ms
4,376 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 4 ms
4,376 KB
testcase_18 AC 5 ms
4,376 KB
testcase_19 AC 5 ms
4,376 KB
testcase_20 AC 5 ms
4,380 KB
testcase_21 AC 4 ms
4,380 KB
testcase_22 AC 4 ms
4,376 KB
testcase_23 AC 5 ms
4,376 KB
testcase_24 AC 5 ms
4,376 KB
testcase_25 AC 5 ms
4,380 KB
testcase_26 AC 5 ms
4,376 KB
testcase_27 AC 5 ms
4,384 KB
testcase_28 AC 5 ms
4,376 KB
testcase_29 AC 5 ms
4,376 KB
testcase_30 AC 5 ms
4,376 KB
testcase_31 AC 5 ms
4,380 KB
testcase_32 AC 5 ms
4,376 KB
testcase_33 AC 5 ms
4,380 KB
testcase_34 AC 5 ms
4,376 KB
testcase_35 AC 4 ms
4,380 KB
testcase_36 AC 5 ms
4,380 KB
testcase_37 AC 5 ms
4,376 KB
testcase_38 AC 5 ms
4,376 KB
testcase_39 AC 5 ms
4,376 KB
testcase_40 AC 5 ms
4,380 KB
testcase_41 AC 5 ms
4,376 KB
testcase_42 AC 5 ms
4,376 KB
testcase_43 AC 5 ms
4,380 KB
testcase_44 AC 5 ms
4,376 KB
testcase_45 AC 5 ms
4,376 KB
testcase_46 AC 5 ms
4,380 KB
testcase_47 AC 6 ms
4,380 KB
testcase_48 AC 5 ms
4,376 KB
testcase_49 AC 6 ms
4,380 KB
testcase_50 AC 5 ms
4,376 KB
testcase_51 AC 5 ms
4,376 KB
testcase_52 AC 5 ms
4,376 KB
testcase_53 AC 5 ms
4,376 KB
testcase_54 AC 5 ms
4,376 KB
testcase_55 AC 6 ms
4,376 KB
testcase_56 AC 5 ms
4,380 KB
testcase_57 AC 5 ms
4,376 KB
testcase_58 AC 5 ms
4,376 KB
testcase_59 AC 6 ms
4,380 KB
testcase_60 AC 6 ms
4,376 KB
testcase_61 AC 6 ms
4,380 KB
testcase_62 AC 6 ms
4,380 KB
testcase_63 AC 4 ms
4,376 KB
testcase_64 AC 4 ms
4,380 KB
testcase_65 AC 4 ms
4,376 KB
testcase_66 AC 4 ms
4,376 KB
testcase_67 AC 4 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e9+7;
const llint big=1e15+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
int main(void){
	//行列累乗
	array<array<llint,27>,27> gyo={0};
	//1
	//3
	//9
	//なし=0
	//あり=1
	//はみ出し=2
	//sta=13
	int i,j,k;
	for(i=0;i<27;i++){
		int U,M,D;
		U=i/9;
		M=(i/3)%3;
		D=i%3;
		for(j=0;j<27;j++){//次
			int ju=j/9,jm=(j/3)%3,jd=j%3;
			if(U==2&&ju!=1){continue;}//前から来たのだから...
			if(M==2&&jm!=1){continue;}
			if(D==2&&jd!=1){continue;}
			if(U==0&&ju==0){continue;}//まだおけるだろ~
			if(M==0&&jm==0){continue;}
			if(D==0&&jd==0){continue;}
			int sumd=0;
			if(U!=2&&ju==1){sumd+=1;}
			if(M!=2&&jm==1){sumd+=2;}
			if(D!=2&&jd==1){sumd+=4;}
			if(sumd%3!=0){continue;}
			if(jm==0&&(ju==0||jd==0)){continue;}//縦にまだおける
			gyo[i][j]=1;
			
		}
		
	}
	array<array<llint,27>,27> gen={0};
	gen[13][13]=1;//last gen[4,10,12,13] こたえ
	llint n;cin>>n;
	for(int bi=0;bi<60;bi++){
		if((n&((llint)1<<bi))!=0){
			array<array<llint,27>,27> iti={0};
			for(i=0;i<27;i++){
				for(j=0;j<27;j++){
					for(k=0;k<27;k++){
						iti[i][k]+=gen[i][j]*gyo[j][k];
						iti[i][k]%=mod;
					}
				}
			}
			gen=iti;
		}
		array<array<llint,27>,27> itii={0};
		for(i=0;i<27;i++){
			for(j=0;j<27;j++){
				
				for(k=0;k<27;k++){
					itii[i][k]+=gyo[i][j]*gyo[j][k];
					itii[i][k]%=mod;
				}
			}
			
		}
		gyo=itii;
	}
	llint ans=0;
	for(i=0;i<27;i++){
		if(i>=18||i%3==2||(i/3)%3==2){continue;}
		ans+=gen[13][i];
	}
	ans%=mod;
	cout<<ans<<endl;
}
0