結果
| 問題 |
No.92 逃走経路
|
| コンテスト | |
| ユーザー |
小指が強い人
|
| 提出日時 | 2015-12-27 01:01:48 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,062 bytes |
| コンパイル時間 | 958 ms |
| コンパイル使用メモリ | 96,160 KB |
| 実行使用メモリ | 10,784 KB |
| 最終ジャッジ日時 | 2024-09-19 07:15:54 |
| 合計ジャッジ時間 | 13,456 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 2 |
| other | TLE * 1 -- * 17 |
ソースコード
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
typedef long long int64;
using namespace std;
unordered_map<int64, unordered_map<int64, unordered_map<int64, bool>>> m3;
vector<int> d;
map<int, bool> res;
int n, m, k;
void solve(int cur, int deep) {
if(deep >= k) {
res[cur] = true;
return;
}
if(m3.count(cur) == 0)
return;
for(auto m2 : m3[cur]) {
if(m2.second.count(d[deep]) != 0) {
solve(m2.first, deep + 1);
}
}
}
int main(void)
{
cin >> n >> m >> k;
for(int i = 0; i < m; i++) {
int64 a, b, c;
cin >> a >> b >> c;
m3[a][b][c] = true;
m3[b][a][c] = true;
}
d.resize(k);
for(int i = 0; i < k; i++) {
cin >> d[i];
}
for(int i = 0; i < n; i++) {
solve(i + 1, 0);
}
bool f = true;
cout << res.size() << endl;
for(auto r : res) {
if(f)
f = false;
else
cout << " ";
cout << r.first;
}
cout << endl;
return 0;
}
小指が強い人