結果

問題 No.2367 Painting Gascket
ユーザー maksimmaksim
提出日時 2023-07-01 01:01:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,923 bytes
コンパイル時間 2,028 ms
コンパイル使用メモリ 185,540 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-21 18:38:57
合計ジャッジ時間 6,192 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 24 ms
4,376 KB
testcase_02 AC 219 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0