結果

問題 No.2733 Just K-times TSP
ユーザー 👑 NachiaNachia
提出日時 2024-04-19 22:02:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 984 bytes
コンパイル時間 927 ms
コンパイル使用メモリ 88,184 KB
実行使用メモリ 17,892 KB
最終ジャッジ日時 2024-04-19 22:02:16
合計ジャッジ時間 1,997 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 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 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 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 6 ms
5,376 KB
testcase_18 AC 5 ms
5,376 KB
testcase_19 AC 5 ms
5,376 KB
testcase_20 AC 3 ms
5,376 KB
testcase_21 AC 5 ms
5,376 KB
testcase_22 AC 36 ms
17,888 KB
testcase_23 AC 5 ms
5,376 KB
testcase_24 AC 24 ms
10,520 KB
testcase_25 AC 23 ms
10,720 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 3 ms
5,376 KB
testcase_30 AC 6 ms
5,376 KB
testcase_31 AC 13 ms
6,628 KB
testcase_32 AC 26 ms
10,400 KB
testcase_33 AC 48 ms
17,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <atcoder/modint>
#define rep(i,n) for(int i=0; i<int(n); i++)
using Modint = atcoder::static_modint<998244353>;
using namespace std;


int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N, M, K; cin >> N >> M >> K;
    vector<int> I; I.push_back(0);
    vector<int> w;
    rep(i,N){
        int z = I.size();
        w.push_back(z);
        rep(j,z*K) I.push_back(I[j] + 1);
    }
    vector<Modint> dp(I.size() * N);
    vector<vector<int>> E(N, vector<int>(N));
    rep(i,M){ int u,v; cin >> u >> v; u--; v--; E[u][v] = E[v][u] = 1; }
    rep(s,N) dp[w[s]*N+s] += 1;
    rep(i,I.size()) rep(p,N){
        rep(q,N) if(E[p][q]){
            int j = i + w[q];
            if(j >= I.size() || I[i] + 1 != I[j]) continue;
            dp[j*N+q] += dp[i*N+p];
        }
    }
    Modint ans = 0;
    rep(i,N) ans += dp[I.size()*N-i-1];
    cout << ans.val() << '\n';
    return 0;
}
0