結果

問題 No.2733 Just K-times TSP
ユーザー FplusFplusFFplusFplusF
提出日時 2024-04-05 15:39:48
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,900 bytes
コンパイル時間 3,656 ms
コンパイル使用メモリ 281,752 KB
実行使用メモリ 28,672 KB
最終ジャッジ日時 2024-04-19 20:50:18
合計ジャッジ時間 6,724 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 7 ms
6,144 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 10 ms
8,960 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 89 ms
28,416 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 14 ms
8,960 KB
testcase_13 AC 4 ms
5,376 KB
testcase_14 AC 108 ms
28,416 KB
testcase_15 WA -
testcase_16 AC 7 ms
6,144 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 8 ms
6,016 KB
testcase_21 AC 19 ms
8,832 KB
testcase_22 WA -
testcase_23 AC 24 ms
9,088 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 3 ms
5,376 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 33 ms
8,960 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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];
    cout << ans << '\n';
}
0