結果

問題 No.92 逃走経路
ユーザー zuvizudarzuvizudar
提出日時 2017-11-03 23:44:21
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,344 bytes
コンパイル時間 752 ms
コンパイル使用メモリ 91,592 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-02 20:45:32
合計ジャッジ時間 1,499 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define INF 1<<25
 
typedef long long ll;

int dy[8]={1,1,1,0,0,-1,-1,-1};
int dx[8]={-1,0,1,-1,1,-1,0,1};
struct S{
	int a,b,c;
};
bool asc(const S& left,const S& right){
	return left.c > right.c;
}
struct edge{
	int to,cost;
};
int N,M,K;
int a[1001],b[1001],c[1001],d[1001];
int dp[1001][101];//i回目にjに居るか
int main(){
	cin>>N>>M>>K;
	rep(i,M)
		cin>>a[i]>>b[i]>>c[i];
	rep(i,K)cin>>d[i];

	rep(i,N){
		if(d[0]==c[i]){
			dp[0][a[i]]=1;
			dp[0][b[i]]=1;
		}
	}
	REP(i,1,K){
		rep(j,M){
			if(d[i]==c[j]){
				if(dp[i-1][a[j]])
					dp[i][b[j]]++;
				if(dp[i-1][b[j]])
					dp[i][a[j]]++;
			}
		}
	}
	vector<int>ans;
	rep(i,N+1){
		if(dp[K-1][i]){
			ans.push_back(i);
		}
	}
	cout<<ans.size()<<endl;
	rep(i,ans.size())cout<<ans[i];
	cout<<endl;
	return 0;
}

0