結果

問題 No.92 逃走経路
ユーザー obaoba
提出日時 2015-01-25 18:08:39
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 7 ms / 5,000 ms
コード長 987 bytes
コンパイル時間 1,633 ms
コンパイル使用メモリ 153,208 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-05 06:18:51
合計ジャッジ時間 2,769 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(a,b,c) for(int a=b; a<(int)c; a++)
#define rep(a,b) REP(a,0,b)
typedef long long int llint;
using namespace std;

int main(){
  int N, M, K;
  cin >> N >> M >> K;
  vector < pair<int,int> > dp[N+1];
  rep(i,M){
	int a,b,c;
	cin >> a >> b >> c;
	dp[a].push_back(pair<int, int>(b,c));
	dp[b].push_back(pair<int, int>(a,c));
  }
  vector <int> d;
  rep(i,K){
	int tmp;
	cin >> tmp;
	d.push_back(tmp);
  }
  vector <bool> tmp1(N+1,true);
  rep(i,d.size()){//nedan
	//	rep(j,tmp1.size())if(tmp1[j]) cout << j << ", ";
	//	cout << endl;
	vector <bool> tmp2(N+1, false);
	rep(l, N+1){//pos
	  if(!tmp1[l]) continue;
	  rep(j, dp[l].size()){
		if(dp[l][j].second == d[i]){
		  // cout << l << ", " << dp[l][j].first << endl;
		  tmp2[dp[l][j].first] = true;
		}
	  }
	}
	rep(j,tmp1.size())tmp1[j] = tmp2[j];
  }
  
  int cnt = 0;
  rep(i,N+1) if(tmp1[i]) cnt++;
  cout << cnt << endl;
  rep(i,N+1)if(tmp1[i]) cout << i << " ";
  cout << endl;

  return 0;
}
0