結果
| 問題 |
No.92 逃走経路
|
| コンテスト | |
| ユーザー |
めうめう🎒
|
| 提出日時 | 2016-03-30 11:18:53 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,292 bytes |
| コンパイル時間 | 1,061 ms |
| コンパイル使用メモリ | 85,756 KB |
| 実行使用メモリ | 1,150,196 KB |
| 最終ジャッジ日時 | 2024-10-02 03:15:27 |
| 合計ジャッジ時間 | 13,746 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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[k - 1 - i];
}
bool used[110] = {};
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){
if(used[now]) continue;
used[now] = true;
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;
}
めうめう🎒