結果
問題 |
No.2367 Painting Gascket
|
ユーザー |
|
提出日時 | 2023-07-01 01:01:39 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,923 bytes |
コンパイル時間 | 2,011 ms |
コンパイル使用メモリ | 187,088 KB |
実行使用メモリ | 15,104 KB |
最終ジャッジ日時 | 2024-07-07 12:14:59 |
合計ジャッジ時間 | 5,571 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 5 TLE * 1 -- * 28 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long const int p=1e9+7; const int maxn=2e5+5; int dp[maxn][4][4][4]; vector<int> go(int x,int y,int z) { vector<int> h={x,y,z}; sort(h.begin(),h.end());h.erase(unique(h.begin(),h.end()),h.end()); map<int,int> h1;for(int i=0;i<h.size();++i) h1[h[i]]=i; vector<int> u; if(x==3) u.push_back(3); else u.push_back(h1[x]); if(y==3) u.push_back(3); else u.push_back(h1[y]); if(z==3) u.push_back(3); else u.push_back(h1[z]); return u; } int32_t main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int n,k;cin>>k>>n; for(int i=0;i<4;++i) { for(int j=0;j<4;++j) { for(int l=0;l<4;++l) { int n1=n; set<int> o;o.insert(i);o.insert(j);o.insert(l); if(o.count(3)) o.erase(3); n1-=o.size(); dp[0][i][j][l]=n1; } } } for(int i=1;i<=k;++i) { for(int j=0;j<4;++j) { for(int l=0;l<4;++l) { for(int m=0;m<4;++m) { for(int u:{0,1,2,4}) { set<int> o;o.insert(j);o.insert(l);o.insert(m); int ways; if(u==4) ways=n-o.size()+o.count(3); else ways=o.count(u); vector<int> v1=go(j,l,u);vector<int> v2=go(l,m,u);vector<int> v3=go(m,j,u); int h=ways; h*=dp[i-1][v1[0]][v1[1]][v1[2]];h%=p; h*=dp[i-1][v2[0]][v2[1]][v2[2]];h%=p; h*=dp[i-1][v3[0]][v3[1]][v3[2]];h%=p; dp[i][j][l][m]+=h;dp[i][j][l][m]%=p; } } } } } cout<<(dp[k][3][3][3]%p+p)%p; return 0; }