結果
| 問題 |
No.92 逃走経路
|
| コンテスト | |
| ユーザー |
ldsyb
|
| 提出日時 | 2017-09-18 03:02:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 833 bytes |
| コンパイル時間 | 798 ms |
| コンパイル使用メモリ | 82,316 KB |
| 実行使用メモリ | 10,144 KB |
| 最終ジャッジ日時 | 2024-11-08 02:06:14 |
| 合計ジャッジ時間 | 13,359 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 2 |
| other | TLE * 1 -- * 17 |
ソースコード
#include <iostream>
#include <vector>
#include <set>
using namespace std;
struct edge{
int to, cost;
edge(int to, int cost){
this->to = to;
this->cost = cost;
}
};
void dfs(vector<vector<edge>> &v, vector<int> &d, set<int> &ans, int k, int now, int count = 0){
if(count == k){
ans.insert(now + 1);
return;
}
for(edge &e:v[now]){
if(e.cost == d[count]){
dfs(v, d, ans, k, e.to, count + 1);
}
}
}
int main(){
int n, m, k;
cin >> n >> m >> k;
vector<vector<edge>> v(n);
while(m--){
int a, b, c;
cin >> a >> b >> c;
a--;
b--;
v[a].emplace_back(edge(b, c));
v[b].emplace_back(edge(a, c));
}
vector<int> d(k);
for(int &x:d) cin >> x;
set<int> ans;
for(int i = 0; i < n; i++){
dfs(v, d, ans, k, i);
}
cout << ans.size() << endl;
for(int x:ans) cout << x << ' ';
cout << endl;
return 0;
}
ldsyb