結果
問題 | No.92 逃走経路 |
ユーザー | naimonon77 |
提出日時 | 2015-12-05 14:45:55 |
言語 | C++11 (gcc 11.4.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,346 bytes |
コンパイル時間 | 439 ms |
コンパイル使用メモリ | 62,728 KB |
実行使用メモリ | 12,192 KB |
最終ジャッジ日時 | 2023-10-12 15:42:37 |
合計ジャッジ時間 | 12,836 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | -- | - |
testcase_02 | -- | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
ソースコード
#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);break; } } for(i++;i<N+1;i++) { if(town[i]) printf(" %d",i); } cout << endl; return 0; }