結果

問題 No.2733 Just K-times TSP
ユーザー GGanariGGanari
提出日時 2024-04-19 23:05:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,053 bytes
コンパイル時間 2,731 ms
コンパイル使用メモリ 208,396 KB
実行使用メモリ 126,720 KB
最終ジャッジ日時 2024-04-19 23:05:50
合計ジャッジ時間 9,809 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,752 KB
testcase_01 AC 2 ms
5,376 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 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 6 ms
5,376 KB
testcase_15 AC 32 ms
5,632 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 156 ms
14,080 KB
testcase_18 AC 329 ms
20,992 KB
testcase_19 AC 613 ms
30,848 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 36 ms
6,944 KB
testcase_22 TLE -
testcase_23 AC 164 ms
14,080 KB
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

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