結果

問題 No.92 逃走経路
ユーザー Sounds_Of_RainSounds_Of_Rain
提出日時 2015-08-04 13:47:15
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 1,351 bytes
コンパイル時間 608 ms
コンパイル使用メモリ 79,024 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 01:02:44
合計ジャッジ時間 1,559 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <functional>
using namespace std;
typedef long long int llint;
const int INF = 1000000;
const llint LINF = 100000000;
//何番目
int black[10000] = { 0 }, bn, wn;
int white[10000] = { 0 };
llint dp[INF];
bool now[101];
bool nex[101];
int main() {
	for (int i = 0; i < 101; i++) {
		now[i] = 1;
		nex[i] = 0;
	}
	llint n, m, k;
	cin >> n >> m >> k;
	vector<llint>b(m);
	vector<llint>a(m);
	vector<llint>c(m);
	vector<llint>d(k);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
		cin >> b[i];
		cin >> c[i];
		a[i]--;
		b[i]--;
	}
	for (int i = 0; i < k; i++) {
		cin >> d[i];
	}
	for (int i = 0; i < k; i++) {
		for (int j = 0; j < m; j++) {
			if (c[j] != d[i])continue;
			else {
				nex[a[j]] |= now[b[j]];
				nex[b[j]] |= now[a[j]];
			}
		}
			for (int j = 0; j < n; j++) {
				now[j] = nex[j];
				nex[j] = 0;
			}
		}
		int ans = 0;
		for (int i = 0; i < n; i++) {
			ans += now[i];
		}
		cout << ans << endl;
		for (int i = 0; i < n; i++) {
			if (now[i]) {
				if(--ans)cout << i + 1 << " ";
				else cout << i + 1 << endl;
			}
		}
			
			//cin >> n;
			return 0;
		}
	
	
0