結果
| 問題 |
No.1598 4×4 Grid
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2021-07-09 22:02:18 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2,130 ms / 4,000 ms |
| コード長 | 1,124 bytes |
| コンパイル時間 | 3,326 ms |
| コンパイル使用メモリ | 153,960 KB |
| 最終ジャッジ日時 | 2025-01-22 21:47:18 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 |
ソースコード
#include <atcoder/all>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace atcoder;
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ull MOD = 1000000007;
using mll = static_modint<1000000007>;
#define rep(i,n) for(int i=0; i<(n); i++)
int C[1<<16];
ll dp[361][1<<16] = {};
vector<int> E[16];
int main(){
C[0] = 0;
rep(i,16) rep(j,1<<i) C[j+(1<<i)] = C[j] + 1;
rep(y,4) rep(x,3) E[y*4+x].push_back(y*4+x+1);
rep(y,4) rep(x,3) E[y*4+x+1].push_back(y*4+x);
rep(y,3) rep(x,4) E[y*4+x].push_back(y*4+x+4);
rep(y,3) rep(x,4) E[y*4+x+4].push_back(y*4+x);
dp[0][0] = 1;
rep(i,1<<16) rep(nx,16) if(0==(i&(1<<nx))){
ll dx = 0;
int c = 15 - C[i];
for(int e : E[nx]){
if(i&(1<<e)) dx -= c;
else dx += c;
}
rep(k,361){
if(k + dx < 0 || 360 < k + dx) continue;
dp[k+dx][i|(1<<nx)] += dp[k][i];
}
}
int K; cin >> K;
cout << dp[K][(1<<16)-1] << endl;
return 0;
}
struct ios_do_not_sync{
ios_do_not_sync(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
} ios_do_not_sync_inst;
Nachia