結果
問題 | No.92 逃走経路 |
ユーザー | startcpp |
提出日時 | 2014-12-07 20:21:44 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 6 ms / 5,000 ms |
コード長 | 1,273 bytes |
コンパイル時間 | 783 ms |
コンパイル使用メモリ | 78,268 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-09-02 09:43:23 |
合計ジャッジ時間 | 1,856 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 6 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,384 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 1 ms
4,380 KB |
testcase_05 | AC | 5 ms
4,380 KB |
testcase_06 | AC | 5 ms
4,380 KB |
testcase_07 | AC | 5 ms
4,380 KB |
testcase_08 | AC | 2 ms
4,376 KB |
testcase_09 | AC | 2 ms
4,380 KB |
testcase_10 | AC | 5 ms
4,376 KB |
testcase_11 | AC | 5 ms
4,380 KB |
testcase_12 | AC | 5 ms
4,380 KB |
testcase_13 | AC | 2 ms
4,376 KB |
testcase_14 | AC | 3 ms
4,376 KB |
testcase_15 | AC | 4 ms
4,376 KB |
testcase_16 | AC | 4 ms
4,380 KB |
testcase_17 | AC | 6 ms
4,384 KB |
testcase_18 | AC | 5 ms
4,380 KB |
testcase_19 | AC | 4 ms
4,380 KB |
ソースコード
#include<iostream> #include<string> #include<algorithm> #include<functional> #include<vector> #include<queue> #include<stack> #include<set> #include<map> #include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> using namespace std; int n,m,k; int a,b,c; int d[1000]; vector<int> to[100]; vector<int> cost[100]; int dp[1001][100]; int main(){ int i,j,l; cin >> n >> m >> k; for( i = 0; i < m; i++ ){ cin >> a >> b >> c; a--;b--; to[a].push_back(b); to[b].push_back(a); cost[a].push_back(c); cost[b].push_back(c); } for( i = 0; i < k; i++ ){ cin >> d[i]; } for( i = 0; i < n; i++ ){ dp[0][i] = 1; } for( i = 0; i < k; i++ ){ for( j = 0; j < n; j++ ){ //cout << dp[i][j] << " " ; if( dp[i][j] == 0 ) continue; for( l = 0; l < to[j].size(); l++ ){ if( cost[j][l] == d[i] ) dp[i+1][ to[j][l] ] = 1; } } //cout << endl; } int maxuse = -1,cnt = 0; for( i = 0; i < n; i++ ){ if( dp[k][i] == 1 ){ cnt++; maxuse = max( maxuse, i ); } } cout << cnt << endl; for( i = 0; i < n; i++ ){ if( dp[k][i] == 1 ){ cout << i+1; if( i != maxuse ) cout << " "; else cout << endl; } } return 0; }