結果

問題 No.2733 Just K-times TSP
ユーザー cled0328cled0328
提出日時 2024-04-19 22:27:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 796 bytes
コンパイル時間 4,259 ms
コンパイル使用メモリ 255,900 KB
実行使用メモリ 15,744 KB
最終ジャッジ日時 2024-04-19 22:27:36
合計ジャッジ時間 5,632 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 9 ms
5,376 KB
testcase_18 AC 11 ms
5,376 KB
testcase_19 AC 13 ms
5,376 KB
testcase_20 AC 4 ms
5,376 KB
testcase_21 AC 19 ms
5,376 KB
testcase_22 AC 86 ms
15,744 KB
testcase_23 AC 10 ms
5,376 KB
testcase_24 AC 58 ms
9,472 KB
testcase_25 AC 57 ms
9,408 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 5 ms
5,376 KB
testcase_30 AC 14 ms
5,376 KB
testcase_31 AC 33 ms
6,016 KB
testcase_32 AC 70 ms
9,472 KB
testcase_33 AC 144 ms
15,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint=modint998244353;

int main(){
    int n,m,k;cin>>n>>m>>k;
    vector<int> u(m),v(m);
    vector<vector<int>> eg(n);
    for(int i=0;i<m;i++){
        cin>>u[i]>>v[i];
        u[i]--;v[i]--;
        eg[u[i]].push_back(v[i]);
        eg[v[i]].push_back(u[i]);
    }
    vector<int> pw(n+1);
    pw[0]=1;
    for(int i=0;i<n;i++)pw[i+1]=pw[i]*(k+1);
    vector<mint> dp(pw[n]*n);
    for(int i=0;i<n;i++)dp[pw[i]*n+i]=1;
    for(int i=0;i<pw[n]*n;i++){
        int pos=i%n;
        for(int j:eg[pos]){
            if(i/n/pw[j]%(k+1)==k)continue;
            dp[i+pw[j]*n-pos+j]+=dp[i];
        }
    }
    mint ans=0;
    for(int i=0;i<n;i++)ans+=dp[(pw[n]-1)*n+i];
    cout<<ans.val()<<"\n";
}
0