結果

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

テストケース

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

ソースコード

diff #

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


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

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

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

	set<int> se;
	for(int i=0;i<n;i++) se.insert(i);
	
	for(int d : v2){
		set<int> se2;
		for (int x : se){
			if(v[x].count(d)){
				for (int y : v[x][d]){
					se2.insert(y);
				}
			}
		}
		se = se2;
	}

	cout << se.size() << endl;
	for(int x : se) cout << x + 1 << " ";
	cout << endl;

	return 0;
}
0