結果

問題 No.92 逃走経路
ユーザー HAHAHAHAHAHA
提出日時 2016-09-06 12:04:02
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 31 ms / 5,000 ms
コード長 609 bytes
コンパイル時間 1,662 ms
コンパイル使用メモリ 175,884 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-27 16:45:19
合計ジャッジ時間 2,750 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 13 ms
6,940 KB
testcase_06 AC 3 ms
6,940 KB
testcase_07 AC 3 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 8 ms
6,940 KB
testcase_10 AC 29 ms
6,948 KB
testcase_11 AC 27 ms
6,940 KB
testcase_12 AC 31 ms
6,944 KB
testcase_13 AC 5 ms
6,944 KB
testcase_14 AC 11 ms
6,940 KB
testcase_15 AC 15 ms
6,940 KB
testcase_16 AC 12 ms
6,944 KB
testcase_17 AC 12 ms
6,944 KB
testcase_18 AC 9 ms
6,940 KB
testcase_19 AC 6 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;


int main(){
	int n,m,k;
	cin >> n >> m >> k;
	vector<map<int,vector<int> > > g(n);

	for(int i=0;i<m;i++){
		int a, b, c;
		cin >> a >> b >> c;
		--a; --b;
		g[a][c].push_back(b);
		g[b][c].push_back(a);
	}

	vector<int> ds(k);
	for(int i=0;i<k;i++) cin >> ds[i];

	set<int> xs;
	for(int i=0;i<n;i++) xs.insert(i);
	
	for(int d : ds){
		set<int> ys;
		for (int x : xs){
			if(g[x].count(d)){
				for (int y : g[x][d]){
					ys.insert(y);
				}
			}
		}
		xs = ys;
	}

	cout << xs.size() << endl;
	for(int x : xs) cout << x + 1 << ' ';
	cout << endl;
	return 0;
}
0