結果

問題 No.1111 コード進行
ユーザー trineutrontrineutron
提出日時 2020-02-10 16:35:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 848 bytes
コンパイル時間 2,453 ms
コンパイル使用メモリ 207,424 KB
実行使用メモリ 13,760 KB
最終ジャッジ日時 2024-04-09 05:10:22
合計ジャッジ時間 7,405 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,760 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,948 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,948 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 3 ms
6,948 KB
testcase_07 AC 3 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 3 ms
6,948 KB
testcase_10 AC 1 ms
6,948 KB
testcase_11 AC 2 ms
6,948 KB
testcase_12 AC 21 ms
6,944 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 772 ms
6,948 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 7 ms
6,944 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 2 ms
6,948 KB
testcase_19 AC 2 ms
6,948 KB
testcase_20 AC 2 ms
6,952 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 2 ms
6,948 KB
testcase_23 AC 2 ms
6,948 KB
testcase_24 AC 2 ms
6,948 KB
testcase_25 AC 105 ms
6,944 KB
testcase_26 TLE -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int dfs(int n, int k, int present, const set<int> &chord, const map<pair<int, int>, int> &seq) {
    if (k < 0) return 0;
    if (n == 0 && k == 0) return 1;
    if (n == 0) return 0;
    int ans = 0;
    for (auto c : chord) {
        if (seq.find(make_pair(present, c)) == seq.end()) continue;
        ans += dfs(n - 1, k - seq.at(make_pair(present, c)), c, chord, seq);
    }
    return ans;
}

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    set<int> chord;
    map<pair<int, int>, int> seq;
    for (int i = 0; i < m; i++) {
        int p, q, c;
        cin >> p >> q >> c;
        chord.insert(p);
        chord.insert(q);
        seq[make_pair(p, q)] = c;
    }
    int ans = 0;
    for (auto c : chord) {
        ans += dfs(n - 1, k, c, chord, seq);
    }
    cout << ans << endl;
}
0