結果

問題 No.2733 Just K-times TSP
ユーザー GGanari
提出日時 2024-04-19 23:05:20
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,053 bytes
コンパイル時間 2,526 ms
コンパイル使用メモリ 207,724 KB
最終ジャッジ日時 2025-02-21 05:21:04
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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<pair<int,vector<int>>,long> mp;
vector<int> graph[10];
vector<int> ed;
long dfs(int x,vector<int> cur)
{
    if(cur == ed)
        return 1;
    if(mp.count({x,cur}))
        return mp[{x,cur}];
    
    mp[{x,cur}] = 0;
    auto &t = mp[{x,cur}];
    for(int y : graph[x])
    {
        if(cur[y] == 0)
            continue;
        cur[y]--;
        t= (t+dfs(y,cur))%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);
    ed = vector<int>(n+1);
    vis[0] = 0;
    for(int i = 1; i<=n; i++)
        graph[0].push_back(i);

    cout << dfs(0,vis) << endl;

    return 0;
}
0