結果

問題 No.92 逃走経路
ユーザー koyumeishikoyumeishi
提出日時 2014-12-07 21:25:44
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,061 bytes
コンパイル時間 757 ms
コンパイル使用メモリ 79,832 KB
実行使用メモリ 12,112 KB
最終ジャッジ日時 2023-09-02 10:40:00
合計ジャッジ時間 13,147 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

struct edge{
	int to;
	int cost;
};


bool dfs( vector<vector<edge> > &G, vector<int> &d, int pos, int x){
	if( x==0 ){
		return true;
	}
	bool ret = false;
	for(int i=0; i<G[pos].size(); i++){
		if( G[pos][i].cost == d[x-1] ){
			ret |= dfs(G,d, G[pos][i].to, x-1);
		}
	}
	return ret;
}


int main(){
	int N,M,K;
	cin >> N >> M >> K;
	vector< vector<edge> > G(N);
	for(int i=0; i<M; i++){
		int a,b,c;
		cin >> a >> b >> c;
		a--;
		b--;
		
		G[a].push_back( (edge){b, c} );
		G[b].push_back( (edge){a, c} );
	}
	
	vector<int> d(K);
	for(int i=0; i<K; i++) cin >> d[i];

	vector<int> ans;
	for(int i=0; i<N; i++){
		if(dfs(G, d, i, K) == true){
			ans.push_back(i);
		}
	}

	cout << ans.size() << endl;
	for(int i=0; i<ans.size(); i++){
		cout << ans[i]+1 << (i==ans.size()-1?"\n" : " ");
	}
	
	
	return 0;
}
0