結果

問題 No.92 逃走経路
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-06-21 21:35:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 168 ms / 5,000 ms
コード長 1,264 bytes
コンパイル時間 702 ms
コンパイル使用メモリ 86,992 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 23:47:37
合計ジャッジ時間 2,108 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 15 ms
5,376 KB
testcase_06 AC 4 ms
5,376 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 18 ms
5,376 KB
testcase_10 AC 86 ms
5,376 KB
testcase_11 AC 102 ms
5,376 KB
testcase_12 AC 168 ms
5,376 KB
testcase_13 AC 8 ms
5,376 KB
testcase_14 AC 22 ms
5,376 KB
testcase_15 AC 51 ms
5,376 KB
testcase_16 AC 42 ms
5,376 KB
testcase_17 AC 61 ms
5,376 KB
testcase_18 AC 29 ms
5,376 KB
testcase_19 AC 14 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pairt
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

int main(void){
	int n, m, k;
	cin >> n >> m >> k;
	int a[1010];
	int b[1010];
	int c[1010];
	rep(i, m){
		int A, B, C;
		scanf("%d %d %d", &A, &B, &C);
		A--; B--;
		a[i] = A; b[i] = B; c[i] = C;
	}
	
	set<int> U1; set<int> U2;
	rep(i, n) U1.insert(i);//初期化
	rep(i, k){//dのクエリを
		int d; scanf("%d", &d);
		for(set<int>::iterator it = U1.begin(); it != U1.end(); it++){
			int tmp = *it;//集合ないの頂点の番号
			rep(j, m){
				if(c[j] == d){
					if(a[j] == tmp) U2.insert(b[j]);
					if(b[j] == tmp) U2.insert(a[j]);
				}
			}

		}
		U1.clear();
		U1 = U2;
		U2.clear();
	}
	
	int size = U1.size();
	printf("%d\n", size);

	for(set<int>::iterator it = U1.begin(); it != U1.end(); it++){
		printf("%d ", *it + 1);
	}
	printf("\n");
	return 0;
}
0