結果
| 問題 |
No.92 逃走経路
|
| コンテスト | |
| ユーザー |
ry0u_yd
|
| 提出日時 | 2015-09-02 09:53:37 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,410 bytes |
| コンパイル時間 | 893 ms |
| コンパイル使用メモリ | 76,448 KB |
| 実行使用メモリ | 272,624 KB |
| 最終ジャッジ日時 | 2024-07-18 17:35:17 |
| 合計ジャッジ時間 | 13,159 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 2 |
| other | TLE * 1 -- * 17 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
struct edge {
int from,to;
int cost;
edge(int t,int c) : to(t),cost(c) {}
edge(int f,int t,int c) : from(f),to(t),cost(c) {}
bool operator<(const edge &e) const {
return cost < e.cost;
}
};
vector<edge> G[105];
vector<int> v,ans;
int n,m,k;
void dfs(int now,int j) {
if(j == k) {
ans.push_back(now);
return;
}
rep(i,G[now].size()) {
edge e = G[now][i];
if(e.cost == v[j]) {
dfs(e.to,j+1);
}
}
}
int main() {
cin >> n >> m >> k;
rep(i,m) {
int a,b,c;
cin >> a >> b >> c;
a--;
b--;
G[a].push_back(edge(b,c));
G[b].push_back(edge(a,c));
}
v.resize(k);
rep(i,k) cin >> v[i];
rep(i,n) {
dfs(i,0);
}
ans.erase(unique(ans.begin(),ans.end()),ans.end());
sort(ans.begin(),ans.end());
cout << ans.size() << endl;
rep(i,ans.size()) {
cout << ans[i]+1;
if(i == ans.size()-1) cout << endl;
else cout << " ";
}
return 0;
}
ry0u_yd