結果

問題 No.2733 Just K-times TSP
ユーザー GGanariGGanari
提出日時 2024-04-19 23:11:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,017 bytes
コンパイル時間 2,113 ms
コンパイル使用メモリ 207,036 KB
実行使用メモリ 133,788 KB
最終ジャッジ日時 2024-04-19 23:11:21
合計ジャッジ時間 8,901 ms
ジャッジサーバーID
(参考情報)
judge6 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,752 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 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 4 ms
5,376 KB
testcase_15 AC 29 ms
5,632 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 142 ms
13,952 KB
testcase_18 AC 301 ms
20,864 KB
testcase_19 AC 545 ms
30,848 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 33 ms
7,040 KB
testcase_22 AC 1,883 ms
126,848 KB
testcase_23 AC 141 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<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