結果

問題 No.1598 4×4 Grid
ユーザー 👑 potato167potato167
提出日時 2021-07-09 23:11:25
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,848 bytes
コンパイル時間 2,116 ms
コンパイル使用メモリ 205,736 KB
実行使用メモリ 210,740 KB
最終ジャッジ日時 2023-09-14 10:44:33
合計ジャッジ時間 35,598 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
using namespace std;
using std::cout;
using std::cin;
using std::endl;
using ll=long long;
using ld=long double;
ll I=1167167167167167167;
ll Q=1e9+7;
#define rep(i,a) for (ll i=0;i<a;i++)
template<class T> using _pq = priority_queue<T, vector<T>, greater<T>>;
template<class T> ll LB(vector<T> &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> ll UB(vector<T> &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}else return 0;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}else return 0;}
template<class T> void So(vector<T> &v) {sort(v.begin(),v.end());}
template<class T> void Sore(vector<T> &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});}
template<class T> void print_tate(vector<T> &v) {rep(i,v.size()) cout<<v[i]<<"\n";}
void yneos(bool a){if(a) cout<<"Yes\n"; else cout<<"No\n";}



//おちこんだりもしたけれど、私はげんきです。
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int K;
	cin>>K;

	vector<vector<ll>> dp((1<<16),vector<ll>(400));
	dp[0][0]=1;
	rep(i,(1<<16)){
		ll X=16;
		rep(j,16){
			if(i&(1<<j)) X--;
		}
		if(X==0) break;
		rep(k,16){
			if(i&(1<<k)) continue;
			int A=0;
			if(k%4!=0){
				A+=1;
				if(i&(1<<(k-1))) A-=2;
			}
			if(k%4!=3){
				A+=1;
				if(i&(1<<(k+1))) A-=2;
			}
			if(k>=4){
				A+=1;
				if(i&(1<<(k-4))) A-=2;
			}
			if(k<12){
				A+=1;
				if(i&(1<<(k+4))) A-=2;
			}
			A*=X;
			//if(i==0) cout<<A<<endl;
			for(int j=min(0,A);j<440-max(0,A);j++){
				//if(dp[i][j]!=0) cout<<dp[i][j]<<" "<<i<<" "<<j<<endl;
				dp[(i|(1<<k))][j+A]+=dp[i][j];
			}
		}
		//cout<<i<<endl;
	}
	cout<<dp[65535][K]<<endl;
	//rep(i,400) cout<<dp[65535][i]<<endl;
}
0