結果

問題 No.92 逃走経路
ユーザー めうめう🎒めうめう🎒
提出日時 2016-03-30 11:11:32
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 1,201 bytes
コンパイル時間 940 ms
コンパイル使用メモリ 83,576 KB
実行使用メモリ 814,720 KB
最終ジャッジ日時 2024-04-10 09:53:45
合計ジャッジ時間 8,839 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
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 <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

vector<pair<int,int> > edge[110];
vector<int> ans;

int his[1010] = {};

int main() {
	int n,m,k;
	int a,b,c;
	cin >> n >> m >> k;
	for(int i = 0;i < m;i++){
		cin >> a >> b >> c;
		a--,b--;
		edge[a].push_back(make_pair(b,c));
		edge[b].push_back(make_pair(a,c));
	}
	for(int i = 0;i < k;i++){
		cin >> his[i];
	}
	for(int i = 0;i < n;i++){
		queue<pair<int,int> > que;
		que.push(make_pair(i,0));
		while(que.size()){
			int now = que.front().first,how = que.front().second;
			que.pop();
			if(how == k){
				ans.push_back(now + 1);
				continue;
			}
			for(int i = 0;i < edge[now].size();i++){
				if(his[how] != edge[now][i].second) continue;
				que.push(make_pair(edge[now][i].first,how + 1));
			}
		}
	}
	//sort(ans.begin(),ans.end());
	cout << ans.size() << endl;
	for(int i = 0;i < ans.size();i++){
		if(i != ans.size() - 1) cout << ans[i] << " ";
		else cout << ans[i];
	}
	cout << endl;
	return 0;
}
0