結果

問題 No.92 逃走経路
ユーザー dnishdnish
提出日時 2017-07-07 09:35:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 799 bytes
コンパイル時間 2,024 ms
コンパイル使用メモリ 174,264 KB
実行使用メモリ 609,496 KB
最終ジャッジ日時 2024-04-16 01:11:20
合計ジャッジ時間 14,657 ms
ジャッジサーバーID
(参考情報)
judge3 / 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 <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int) N;i++)
#define F first
#define S second
using namespace std;

vector<pair<int,int>> edge[110];
vector<int> ok;
int d[1010];
int main() {
	int N,M,K;
	cin>>N>>M>>K;
	REP(i,0,M){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		edge[a].push_back({b,c});
		edge[b].push_back({a,c});
	}
	REP(i,0,K) cin>>d[i];
	REP(i,0,N) ok.push_back(i);
	REP(k,0,K){
		vector<int> tmp;
		for(auto next:ok){
			REP(j,0,edge[next].size()){
				if(edge[next][j].S==d[k]) tmp.push_back(edge[next][j].F);
			}
		}
		tmp.erase(unique(tmp.begin(),tmp.end()),tmp.end());
		ok=tmp;
	}
	cout<<ok.size()<<endl;
	sort(ok.begin(),ok.end());
	bool flag=false;
	for(auto v:ok)	{
		if(!flag) {
			cout<<v+1;
			flag=true;
		}
		else cout<<" "<<v+1;
	}
	cout<<"";
	return 0;
}
0