結果

問題 No.92 逃走経路
ユーザー tkmst201tkmst201
提出日時 2017-04-30 10:30:49
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,245 bytes
コンパイル時間 1,409 ms
コンパイル使用メモリ 161,468 KB
実行使用メモリ 265,696 KB
最終ジャッジ日時 2023-10-11 23:31:49
合計ジャッジ時間 13,981 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
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>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<61;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int n, m, K;
map<ll, vector<pii> > g;

int main() {
	cin >> n >> m >> K;
	REP(i, m) {
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		a--; b--;
		g[c].push_back(pii(a, b));
		g[c].push_back(pii(b, a));
	}
	
	vector<int> ans;
	REP(i, n) ans.push_back(i);
	
	REP(i, K) {
		int d;
		scanf("%d", &d);
		
		vector<pii> &gn = g[d];
		
		vector<int> now;
		REP(j, ans.size()) {
			REP(k, gn.size()) if (gn[k].first == ans[j])
				now.push_back(gn[k].second);
		}
		
		ans = now;
	}
	
	sort(ALL(ans));
	ans.erase(unique(ALL(ans)), ans.end());
	
	cout << ans.size() << endl;
	REP(i, ans.size()) printf("%d%c", ans[i] + 1, i == ans.size() - 1 ? '\n' : ' ');
	
	return 0;
}
0