結果

問題 No.92 逃走経路
ユーザー 沙耶花
提出日時 2021-10-23 09:21:00
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 10 ms / 5,000 ms
コード長 826 bytes
コンパイル時間 5,007 ms
コンパイル使用メモリ 256,012 KB
最終ジャッジ日時 2025-01-25 04:54:07
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000



int main(){
	
	int N,M,K;
	cin>>N>>M>>K;
	
	vector<vector<pair<int,int>>> E(N);
	rep(i,M){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		E[a].emplace_back(b,c);
		E[b].emplace_back(a,c);
	}
	
	vector<bool> dp(N,true);
	rep(i,K){
		int d;
		cin>>d;
		vector<bool> ndp(N,false);
		rep(j,N){
			if(dp[j]==false)continue;
			rep(k,E[j].size()){
				if(E[j][k].second==d){
					ndp[E[j][k].first] = true;
				}
			}
		}
		swap(dp,ndp);
	}
	
	vector<int> ans;
	rep(i,N){
		if(dp[i])ans.push_back(i+1);
	}
	
	cout<<ans.size()<<endl;
	rep(i,ans.size()){
		if(i!=0)cout<<' ';
		cout<<ans[i];
	}
	cout<<endl;

	
	return 0;
}
0