結果

問題 No.92 逃走経路
ユーザー Ysmr_RyYsmr_Ry
提出日時 2014-12-14 11:30:18
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 7 ms / 5,000 ms
コード長 1,012 bytes
コンパイル時間 464 ms
コンパイル使用メモリ 43,876 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-02 14:29:56
合計ジャッジ時間 1,877 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 5 ms
4,376 KB
testcase_06 AC 5 ms
4,380 KB
testcase_07 AC 5 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,376 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 3 ms
4,380 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 6 ms
4,376 KB
testcase_18 AC 5 ms
4,376 KB
testcase_19 AC 5 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<cstring>
#include<vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repd(i,a) for(int i=(a);i>=0;--i)
#define clr(a,v) memset((a),(v),sizeof(a))
#define all(a) (a).begin(), (a).end()

typedef std::pair<int, int> P;

int N, M, K;
int d[1000];
std::vector<P> G[100];
bool dp[1001][100];

int main()
{
	scanf( "%d%d%d", &N, &M, &K );
	rep( i, M )
	{
		int a, b, c;
		scanf( "%d%d%d", &a, &b, &c );
		--a; --b;
		G[a].push_back( P( b, c ) );
		G[b].push_back( P( a, c ) );
	}
	rep( i, K )
		scanf( "%d", d+i );

	rep( j, N )
		dp[0][j] = true;

	rep( i, K )
	{
		rep( j, N ) rep( k, G[j].size() )
		{
			const P &e = G[j][k];

			if( e.second != d[i] )
				continue;

			dp[i+1][e.first] |= dp[i][j];
		}
	}

	std::vector<int> v;
	rep( j, N ) if( dp[K][j] )
		v.push_back( j+1 );

	printf( "%d\n", v.size() );

	rep( i, v.size() )
		printf( "%d%c", v[i], i==v.size()-1?'\n':' ' );

	return 0;
}
0