結果
| 問題 | No.1111 コード進行 |
| コンテスト | |
| ユーザー |
trineutron
|
| 提出日時 | 2020-02-10 16:35:15 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 848 bytes |
| 記録 | |
| コンパイル時間 | 2,282 ms |
| コンパイル使用メモリ | 221,872 KB |
| 実行使用メモリ | 13,056 KB |
| 最終ジャッジ日時 | 2026-06-08 18:15:18 |
| 合計ジャッジ時間 | 6,998 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 24 TLE * 1 -- * 23 |
ソースコード
#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;
}
trineutron