結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,380 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 <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 k;
int N;
int M;
int K;
int iCnt;

	cin >> N;
	cin >> M;
	cin >> K;
	for( i = 1; i <= M; i++ )
	{
		cin >> R[ i ].a;
		cin >> R[ i ].b;
		cin >> R[ i ].c;
	}

	for( i = 1; i <= K; i++ ) cin >> d[ i ];

	for( i = 1; i <= N; i++ ) bPre[ i ] = true;

	for( i = 1; i <= K; i++ )
	{
		for( k = 1; k <= N; k++ ) b[ k ] = false;

		for( j = 1; j <= M; j++ )
		{
			if( d[ i ] != R[ j ].c ) continue;

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

		for( k = 1; k <= N; k++ ) bPre[ k ] = b[ k ];
	}

	iCnt = 0;
	for( k = 1; k <= N; k++ )
	{
		if( b[ k ] ) iCnt++;
	}

	cout << iCnt << endl;
	for( i = 1; i <= N; i++ )
	{
		if( b[ i ] ) cout << i << endl;
	}

	return 0;
}
0