結果
問題 | No.92 逃走経路 |
ユーザー |
![]() |
提出日時 | 2016-03-30 11:11:32 |
言語 | C++11 (gcc 13.3.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,201 bytes |
コンパイル時間 | 1,066 ms |
コンパイル使用メモリ | 83,704 KB |
実行使用メモリ | 816,256 KB |
最終ジャッジ日時 | 2024-10-02 11:43:12 |
合計ジャッジ時間 | 10,057 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 2 |
other | MLE * 1 -- * 17 |
ソースコード
#include <algorithm> #include <cstdio> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define ll long long #define INF (1 << 30) #define INFLL (1LL << 60) vector<pair<int,int> > edge[110]; vector<int> ans; int his[1010] = {}; int main() { int n,m,k; int a,b,c; cin >> n >> m >> k; for(int i = 0;i < m;i++){ cin >> a >> b >> c; a--,b--; edge[a].push_back(make_pair(b,c)); edge[b].push_back(make_pair(a,c)); } for(int i = 0;i < k;i++){ cin >> his[i]; } for(int i = 0;i < n;i++){ queue<pair<int,int> > que; que.push(make_pair(i,0)); while(que.size()){ int now = que.front().first,how = que.front().second; que.pop(); if(how == k){ ans.push_back(now + 1); continue; } for(int i = 0;i < edge[now].size();i++){ if(his[how] != edge[now][i].second) continue; que.push(make_pair(edge[now][i].first,how + 1)); } } } //sort(ans.begin(),ans.end()); cout << ans.size() << endl; for(int i = 0;i < ans.size();i++){ if(i != ans.size() - 1) cout << ans[i] << " "; else cout << ans[i]; } cout << endl; return 0; }