結果

問題 No.1598 4×4 Grid
ユーザー kotatsugamekotatsugame
提出日時 2021-07-09 22:02:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 371 ms / 4,000 ms
コード長 441 bytes
コンパイル時間 1,697 ms
コンパイル使用メモリ 64,868 KB
実行使用メモリ 84,116 KB
最終ジャッジ日時 2023-09-14 09:06:52
合計ジャッジ時間 4,195 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
4,932 KB
testcase_01 AC 96 ms
31,300 KB
testcase_02 AC 100 ms
30,140 KB
testcase_03 AC 212 ms
52,632 KB
testcase_04 AC 277 ms
67,516 KB
testcase_05 AC 363 ms
83,472 KB
testcase_06 AC 371 ms
84,116 KB
testcase_07 AC 9 ms
4,376 KB
testcase_08 AC 97 ms
29,624 KB
testcase_09 AC 291 ms
72,412 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:5:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    5 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int K;
long dp[217][1<<16];
main()
{
	cin>>K;
	dp[0][0]=1;
	for(int i=0;i<1<<16;i++)
	{
		int t=0;
		for(int x=0;x<4;x++)for(int y=0;y<4;y++)
		{
			if(x<3&&(i>>x*4+y&1)!=(i>>x*4+4+y&1))t++;
			if(y<3&&(i>>x*4+y&1)!=(i>>x*4+y+1&1))t++;
		}
		for(int l=0;l<16;l++)if(!(i>>l&1))
		{
			for(int j=0;j+t<=K;j++)if(dp[j][i])
			{
				dp[j+t][i|1<<l]+=dp[j][i];
			}
		}
	}
	cout<<dp[K][(1<<16)-1]<<endl;
}
0