結果

問題 No.2733 Just K-times TSP
ユーザー otoshigootoshigo
提出日時 2024-04-19 22:36:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,533 bytes
コンパイル時間 2,307 ms
コンパイル使用メモリ 203,136 KB
実行使用メモリ 48,896 KB
最終ジャッジ日時 2024-04-19 22:36:52
合計ジャッジ時間 4,002 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 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 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 WA -
testcase_16 AC 3 ms
5,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 6 ms
5,376 KB
testcase_21 AC 14 ms
7,296 KB
testcase_22 WA -
testcase_23 AC 16 ms
7,296 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 21 ms
7,296 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

const int MOD=998244353;

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int N,M,K;
    cin>>N>>M>>K;
    vector<vector<int>>G(N);
    for(int i=0;i<M;i++){
        int u,v;
        cin>>u>>v;
        u--;
        v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    int L=1;
    for(int i=0;i<N;i++)L*=K+1;
    vector dp(L,vector<ll>(N));
    for(int i=0;i<N;i++){
        int at=0;
        for(int j=0;j<N;j++){
            at=(K+1)*at+(i==j?1:0);
        }
        dp[at][i]=1;
    }
    for(int bit=0;bit<L;bit++){
        int b=bit;
        vector<int>v(N);
        for(int i=N-1;i>=0;i--){
            v[i]=b%(K+1);
            b/=K+1;
        }
        for(int i=0;i<N;i++){
            for(auto j:G[i]){
                if(v[j]<K){
                    int c=0;
                    for(int k=0;k<N;k++){
                        c=(K+1)*c+(k==j?v[k]+1:v[k]);
                    }
                    dp[c][j]+=dp[bit][i];
                    dp[c][j]%=MOD;
                }
            }
        }
    }
    ll ans=0;
    for(int i=0;i<N;i++)ans+=dp[L-1][i];
    cout<<ans<<"\n";
}
0