結果

問題 No.92 逃走経路
ユーザー 西尾西尾
提出日時 2018-03-22 16:20:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 854 bytes
コンパイル時間 1,497 ms
コンパイル使用メモリ 165,740 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-07 01:31:28
合計ジャッジ時間 2,594 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define rep1( i, n )	for( int i = 1; i <= n; i++ )

#include <bits/stdc++.h>
using namespace std;

struct Root
{
	int a;
	int b;
	int c;
};

Root R[ 1010 ];
int d[ 1010 ];

bool bPre[ 110 ];
bool b[ 110 ];

int main()
{
int i;
int j;
int m;
int N;
int M;
int K;
int iCnt;

	cin >> N;
	cin >> M;
	cin >> K;
	rep1( i, M )
	{
		cin >> R[ i ].a;
		cin >> R[ i ].b;
		cin >> R[ i ].c;
	}

	rep1( m, K ) cin >> d[ m ];

	rep1( i, N ) bPre[ i ] = true;

	rep1( m, K )
	{
		rep1( i, N ) b[ i ] = false;

		rep1( j, M )
		{
			if( d[ m ] != R[ j ].c ) continue;

			if( bPre[ R[ j ].a ] ) b[ R[ j ].b ] = true;
			if( bPre[ R[ j ].b ] ) b[ R[ j ].a ] = true;
		}

		rep1( i, N ) bPre[ i ] = b[ i ];
	}

	iCnt = 0;
	rep1( i, N )
	{
		if( b[ i ] ) iCnt++;
	}

	cout << iCnt << endl;
	rep1( i, N )
	{
		if( b[ i ] ) cout << i << " ";
	}

	cout << endl;
	return 0;
}
0