結果

問題 No.92 逃走経路
ユーザー dnishdnish
提出日時 2017-07-07 10:15:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 832 bytes
コンパイル時間 1,907 ms
コンパイル使用メモリ 168,940 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 01:12:11
合計ジャッジ時間 2,596 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int) N;i++)
#define F first
#define S second
using namespace std;

vector<pair<int,int>> edge[110];
bool visit[2][110];
int d[1010];
int main() {
	int N,M,K;
	cin>>N>>M>>K;
	REP(i,0,M){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		edge[a].push_back({b,c});
		edge[b].push_back({a,c});
	}
	REP(i,0,K) cin>>d[i];
	REP(i,0,N) visit[0][i]=true;
	REP(k,0,K){
		int now=k%2;
		REP(i,0,N) visit[1-now][i]=false;
		REP(i,0,N){
			if(visit[now][i]){
				REP(j,0,edge[i].size()){
					if(edge[i][j].S==d[k]) {
						visit[1-now][edge[i][j].F]=true;
					}
				}
			}
		}
	}
	cout<<count(visit[K%2],visit[K%2]+N,true)<<endl;

	bool flag=false;
	REP(i,0,N){
		if(!visit[K%2][i]) continue;
		if(!flag) {
			cout<<i+1;
			flag=true;
		}
		else cout<<" "<<i+1;
	}
	cout<<endl;
	return 0;
}
0