結果
問題 | No.2733 Just K-times TSP |
ユーザー |
![]() |
提出日時 | 2024-04-05 15:41:07 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 292 ms / 2,000 ms |
コード長 | 1,946 bytes |
コンパイル時間 | 3,492 ms |
コンパイル使用メモリ | 252,804 KB |
実行使用メモリ | 28,288 KB |
最終ジャッジ日時 | 2024-10-11 13:07:47 |
合計ジャッジ時間 | 6,521 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll=long long;using pll=pair<ll,ll>;using tll=tuple<ll,ll,ll>;using ld=long double;const ll INF=(1ll<<60);#define rep(i,n) for (ll i=0;i<(ll)(n);i++)#define all(v) v.begin(),v.end()template<class T> inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}template<class T> inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}ll dp[9][9][9][9][9][9][6];int main(){const ll mod=998244353;ios::sync_with_stdio(false);cin.tie(nullptr);ll n,m,k;cin >> n >> m >> k;vector<vector<ll>> g(n);while(m--){ll u,v;cin >> u >> v;u--;v--;g[u].push_back(v);g[v].push_back(u);}vector<ll> v(6,k);rep(i,6){if(i<n) v[i]=0;}rep(i,n){v[i]++;dp[v[0]][v[1]][v[2]][v[3]][v[4]][v[5]][i]=1;v[i]--;}rep(a,k+1){rep(b,k+1){rep(c,k+1){rep(d,k+1){rep(e,k+1){rep(f,k+1){rep(i,n){for(auto j:g[i]){v={a,b,c,d,e,f};v[j]++;if(v[j]<=k){dp[v[0]][v[1]][v[2]][v[3]][v[4]][v[5]][j]+=dp[a][b][c][d][e][f][i];if(mod<=dp[v[0]][v[1]][v[2]][v[3]][v[4]][v[5]][j]) dp[v[0]][v[1]][v[2]][v[3]][v[4]][v[5]][j]-=mod;}}}}}}}}}ll ans=0;rep(i,n){ans+=dp[k][k][k][k][k][k][i];if(mod<=ans) ans-=mod;}cout << ans << '\n';}