結果

問題 No.92 逃走経路
ユーザー sggkshio
提出日時 2018-03-07 08:19:31
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 50 ms / 5,000 ms
コード長 1,266 bytes
コンパイル時間 923 ms
コンパイル使用メモリ 86,220 KB
実行使用メモリ 28,192 KB
最終ジャッジ日時 2024-09-24 16:43:53
合計ジャッジ時間 2,407 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>
using namespace std;

//#include<bits/stdc++.h>

vector<long long int> f[1005][1005];

int main() {
	/*
	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			f[i][j] = 100000000000;
		}
	}
	*/

	int n, m, k;
	
	cin >> n >> m >> k;
	for (int i = 0; i < m; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		f[a][b].push_back(c);
		f[b][a].push_back(c);
	}
	int x = n;
	bool g[1005][1005] = {};
	for (int i = 0; i <= n; i++) {
		g[0][i] = 1;
	}
	for (int i = 0; i < k; i++) {
		int d;
		cin >> d;
		for (int j = 1; j <= n; j++) {
			for (int y = 1; y <= n; y++) {
				//cout << f[i][j];
				for(int t=0;t<f[j][y].size();t++)
				if (f[j][y][t] == d) {
				//	cout << "#"; cout << i << j;
					g[i + 1][y] += g[i][j];
				}
			}
			
		}
	}
	x = 0;
	for (int i = 0; i <= n; i++)x += g[k][i];
	cout << x << endl;
	for (int i = 1; i <= n; i++) {
		if (!g[k][i])continue;
		cout << i << " ";

	}
	cout << endl;

	return 0;
}
0