結果

問題 No.2733 Just K-times TSP
ユーザー GGanari
提出日時 2024-04-19 23:11:08
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,017 bytes
コンパイル時間 2,544 ms
コンパイル使用メモリ 206,624 KB
最終ジャッジ日時 2025-02-21 05:26:52
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21 TLE * 2 -- * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define INF 1000000001LL
#define LNF 1000000000000000001LL
#define MOD 998244353LL
#define MAX 1005
#define long long long
#define all(x) x.begin(),x.end()
using namespace std;

map<vector<int>,long> mp;
vector<int> graph[10];
long dfs(int x,vector<int> cur, int sum)
{
    if(sum == 0)
        return 1;
    if(mp.count(cur))
        return mp[cur];
    mp[cur] = 0;
    auto &t = mp[cur];
    for(int y : graph[x])
    {
        if(cur[y] == 0)
            continue;
        cur[0] = y;
        cur[y]--;
        t= (t+dfs(y,cur,sum-1))%MOD;
        cur[y]++;
    }
    return t;
}
int main()
{
	ios_base::sync_with_stdio(0); 
    cin.tie(0);
    
    int n,m,k;
    cin >> n >> m >> k;

    for(int i = 0; i<m; i++)
    {
        int a,b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    vector<int> vis(n+1,k);
    vis[0] = 0;
    for(int i = 1; i<=n; i++)
        graph[0].push_back(i);

    cout << dfs(0,vis,k*n) << endl;

    return 0;
}
0