結果

問題 No.997 Jumping Kangaroo
ユーザー kotatsugamekotatsugame
提出日時 2020-02-21 22:37:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,460 bytes
コンパイル時間 568 ms
コンパイル使用メモリ 69,344 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-17 07:45:23
合計ジャッジ時間 14,852 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
9,344 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 TLE -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
5,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 236 ms
5,376 KB
testcase_14 AC 1,175 ms
5,376 KB
testcase_15 WA -
testcase_16 TLE -
testcase_17 AC 6 ms
5,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int W,N;
long K;
int A[99];
long mod=1e9+7,D[160][160];
long X[2][160];
long E[160][160];
main()
{
	cin>>N>>W>>K;
	for(int i=0;i<N;i++)cin>>A[i];
	for(int k=0;k<2;k++)for(int i=0;i<2*W;i++)
	{
		for(int j=0;j<2;j++)for(int l=0;l<4*W;l++)X[j][l]=0;
		X[k][i]=1;
		for(int j=i;j<2*W;j++)for(int l=0;l<2;l++)
		{
			for(int I=0;I<N;I++)
			{
				if(j+A[I]<4*W)
				{
					int nl=l;
					if((j+A[I])%W==0)nl=0;
					else nl+=(j+A[I])/W-j/W;
					if(nl<=1)(X[nl][j+A[I]]+=X[l][j])%=mod;
				}
			}
		}
		for(int j=0;j<2;j++)for(int l=0;l<2*W;l++)
		{
			D[j*2*W+l][k*2*W+i]=X[j][l+2*W];
		}
	}
	for(int i=0;i<4*W;i++)E[i][i]=1;
	long KK=K/2;
	while(KK>0)
	{
		if(KK&1)
		{
			long tmp[160][160]={};
			for(int i=0;i<4*W;i++)for(int j=0;j<4*W;j++)for(int k=0;k<4*W;k++)
			{
				tmp[i][j]+=E[i][k]*D[k][j]%mod;
			}
			for(int i=0;i<4*W;i++)for(int j=0;j<4*W;j++)E[i][j]=tmp[i][j]%mod;
		}
		KK>>=1;
		long tmp[160][160]={};
		for(int i=0;i<4*W;i++)for(int j=0;j<4*W;j++)for(int k=0;k<4*W;k++)
		{
			tmp[i][j]+=D[i][k]*D[k][j]%mod;
		}
		for(int i=0;i<4*W;i++)for(int j=0;j<4*W;j++)D[i][j]=tmp[i][j]%mod;
	}
	long ans[160]={};
	for(int i=0;i<4*W;i++)ans[i]=E[i][0];
	for(int j=0;j<2*W;j++)for(int i=0;i<2;i++)
	{
		for(int I=0;I<N;I++)
		{
			if(j+A[I]<2*W)
			{
				int nl=i;
				if((j+A[I])%W==0)nl=0;
				else nl+=(j+A[I])/W-j/W;
				if(nl<2)(ans[nl*2*W+j+A[I]]+=ans[i*2*W+j])%=mod;
			}
		}
	}
	cout<<ans[K%2*W]<<endl;
}
0