結果

問題 No.2733 Just K-times TSP
ユーザー umezoumezo
提出日時 2024-04-19 23:15:44
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 314 ms / 2,000 ms
コード長 905 bytes
コンパイル時間 4,318 ms
コンパイル使用メモリ 278,848 KB
実行使用メモリ 28,520 KB
最終ジャッジ日時 2024-04-19 23:16:22
合計ジャッジ時間 5,154 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 3 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 8 ms
6,944 KB
testcase_18 AC 15 ms
6,940 KB
testcase_19 AC 26 ms
6,944 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 5 ms
6,940 KB
testcase_22 AC 68 ms
21,100 KB
testcase_23 AC 9 ms
6,944 KB
testcase_24 AC 105 ms
15,720 KB
testcase_25 AC 89 ms
15,872 KB
testcase_26 AC 1 ms
6,940 KB
testcase_27 AC 1 ms
6,940 KB
testcase_28 AC 4 ms
6,940 KB
testcase_29 AC 10 ms
6,940 KB
testcase_30 AC 27 ms
6,944 KB
testcase_31 AC 67 ms
8,832 KB
testcase_32 AC 152 ms
15,744 KB
testcase_33 AC 314 ms
28,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
template <class T> using V=vector<T>;
template <class T> using VV=V<V<T>>; //B(n,V<int>(n))
 
ll dp[600000][6];
V<int> G[6];
const int MOD=998244353;
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  ll n,m,k;
  cin>>n>>m>>k;
  V<ll> A(n+1);
  A[0]=1;
  rep(i,n) A[i+1]=A[i]*(k+1);
  rep(i,m){
    int u,v;
    cin>>u>>v;
    u--,v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  rep(i,n) dp[A[i]][i]=1;
  for(int i=0;i<A[n];i++){
    for(int j=0;j<n;j++){
      if(dp[i][j]==0) continue;
      for(auto nv:G[j]){
        if((i/A[nv])%(k+1)==k) continue;
        dp[i+A[nv]][nv]=(dp[i+A[nv]][nv]+dp[i][j])%MOD;
      }
    }
  }
  ll ans=0;
  rep(i,n){
    ans=(ans+dp[A[n]-1][i])%MOD;
  }
  cout<<ans<<endl;
    
  return 0;
}
0