結果
問題 | No.1598 4×4 Grid |
ユーザー |
![]() |
提出日時 | 2021-07-09 22:02:18 |
言語 | C++17 (gcc 11.2.0 + boost 1.78.0) |
結果 |
AC
|
実行時間 | 1,860 ms / 4,000 ms |
コード長 | 1,124 bytes |
コンパイル時間 | 2,565 ms |
使用メモリ | 188,676 KB |
最終ジャッジ日時 | 2023-02-01 23:34:56 |
合計ジャッジ時間 | 23,748 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 1,853 ms
188,528 KB |
testcase_01 | AC | 1,852 ms
188,664 KB |
testcase_02 | AC | 1,841 ms
188,620 KB |
testcase_03 | AC | 1,845 ms
188,556 KB |
testcase_04 | AC | 1,845 ms
188,592 KB |
testcase_05 | AC | 1,850 ms
188,664 KB |
testcase_06 | AC | 1,842 ms
188,532 KB |
testcase_07 | AC | 1,835 ms
188,524 KB |
testcase_08 | AC | 1,860 ms
188,676 KB |
testcase_09 | AC | 1,840 ms
188,624 KB |
ソースコード
#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;