結果

問題 No.2733 Just K-times TSP
ユーザー ococonomy1ococonomy1
提出日時 2024-04-19 22:40:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,806 bytes
コンパイル時間 1,618 ms
コンパイル使用メモリ 125,472 KB
実行使用メモリ 116,736 KB
最終ジャッジ日時 2024-04-19 22:40:33
合計ジャッジ時間 8,822 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 3 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 5 ms
5,376 KB
testcase_15 AC 29 ms
5,632 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 155 ms
13,952 KB
testcase_18 AC 288 ms
20,864 KB
testcase_19 AC 594 ms
30,848 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 36 ms
6,528 KB
testcase_22 AC 1,997 ms
111,360 KB
testcase_23 AC 155 ms
12,672 KB
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pli = pair<ll,int>;
#define TEST cerr << "TEST" << endl
#define AMARI 998244353
//#define AMARI 1000000007
#define el '\n'
#define El '\n'

int n,m,k;
map<pair<vector<int>,int>,ll> mp;
vector<vector<int>> g;
ll saiki(vector<int> & a,int v){
    /*
    for(int i = 0; i < n; i++){
        cerr << a[i] << ' ';
    }
    cerr << el;
    */
    if(mp.find(pair(a,v)) != mp.end())return mp[pair(a,v)];
    ll ans = 0;
    for(int i = 0; i < g[v].size(); i++){
        if(a[g[v][i]] >= k)continue;
        a[g[v][i]]++;
        ans += saiki(a,g[v][i]);
        if(ans >= AMARI)ans -= AMARI;
        a[g[v][i]]--;
    }
    /*
    for(int i = 0; i < n; i++){
        cerr << a[i] << ' ';
    }
    cerr << ans << el;
    */
    
    return mp[pair(a,v)] = ans;
}

#define MULTI_TEST_CASE false
void solve(void){
    //問題を見たらまず「この問題設定から言えること」をいっぱい言う
    //一個回答に繋がりそうな解法が見えても、実装や細かい詰めに時間がかかりそうなら別の方針を考えてみる
    //添え字回りで面倒になりそうなときは楽になる言い換えを実装の前にじっくり考える
    //ある程度考察しても全然取っ掛かりが見えないときは実験をしてみる
    //よりシンプルな問題に言い換えられたら、言い換えた先の問題を自然言語ではっきりと書く

    //M <= 15
    //K == 1 なら bitDP ができる
    // dp[i][j][S] = (iからスタートして今 j にいて、使った点の集合が S のものが何通りあるか)
    //K^N が意外と小さいので、 bitDP の (k+1)進 ver が通る
    cin >> n;
    cin >> m >> k;
    g.resize(n);
    while(m--){
        int u,v;
        cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<int> b(n,k);
    for(int i = 0; i < n; i++){
        mp[pair(b,i)] = 1;
    }

    vector<int> a(n,0);
    ll ans = 0;
    for(int i = 0; i < n; i++){
        a[i]++;
        ans += saiki(a,i);
        a[i]--;
    }
    cout << ans % AMARI << el;
    
    return;
}

void calc(void){
    return;
}

signed main(void){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    calc();
    int t = 1;
    if(MULTI_TEST_CASE)cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
0