結果

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

テストケース

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

ソースコード

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 << " ";
	}

	cout << endl;
	return 0;
}
0