結果
| 問題 | No.92 逃走経路 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-12-05 14:43:16 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,263 bytes |
| 記録 | |
| コンパイル時間 | 444 ms |
| コンパイル使用メモリ | 84,844 KB |
| 実行使用メモリ | 10,112 KB |
| 最終ジャッジ日時 | 2026-04-04 13:08:04 |
| 合計ジャッジ時間 | 12,924 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 2 |
| other | TLE * 1 -- * 17 |
ソースコード
#include <iostream>
#include <cstring>
#include <algorithm>
#include <limits.h>
#include <cmath>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
/* ここからが本編 */
/* */
int N,M,K;
int a[1000];
int b[1000];
int c[1000];
int d[1000];
int town[101] = {0};
int town_n = 0;
int target;
void town_search(int before,int i,int j)
{
int k,l;
int cnt = 0;
if(j == K) {
town[target] = 1;
town_n++;
return ;
}
for(k=0;k<M;k++) {
if(d[K-1-j] == c[k] && before == b[k]) {
town_search(a[k],i,j+1);
}
}
for(k=0;k<M;k++) {
if(d[K-1-j] == c[k] && before == a[k]) {
town_search(a[k],i,j+1);
}
}
}
int main(void)
{
int test = 1;
int i,j,k,l;
cin >> N >> M >> K;
rep(i,M) {
scanf("%d %d %d",&a[i],&b[i],&c[i]);
if(a[i] < b[i]) swap(a[i],b[i]);
// a[i] >= b[i] になる
}
rep(i,K) {
scanf("%d",&d[i]);
}
for(i=0;i<M;i++) {
if(c[i] != d[K-1]) continue;
target = b[i];
town_search(a[i],i,1);
target = a[i];
town_search(b[i],i,1);
}
cout << town_n << endl;
for(i=1;i<N+1;i++) {
if(town[i]) printf("%d ",i);
}
cout << endl;
return 0;
}