結果
| 問題 |
No.92 逃走経路
|
| コンテスト | |
| ユーザー |
Zu_rin
|
| 提出日時 | 2020-09-09 11:43:07 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 16 ms / 5,000 ms |
| コード長 | 1,260 bytes |
| コンパイル時間 | 935 ms |
| コンパイル使用メモリ | 89,684 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-14 15:56:21 |
| 合計ジャッジ時間 | 1,821 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30
using namespace std;
typedef long long ll;
typedef pair<int, int> pp;
void DFS(int n, int dep, vector<list<pp>> & d, vector<int> & t, set<int> &ans, vector<vector<int>> &dp) {
if (dep == t.size()) {
ans.insert(n);
return;
}
if (dp[n][dep])
return;
dp[n][dep] = 1;
int& x = t[dep];
for (auto it = d[n].begin(); it != d[n].end(); it++) {
if ((*it).first == x) {
DFS((*it).second, dep + 1, d, t, ans, dp);
}
}
return;
}
int main(void) {
int num, m, k, i, a, b, c;
cin >> num >> m >> k;
vector<list<pp>> d(num + 1);
vector<vector<int>> dp(num + 1, vector<int>(k, 0));
vector<int> t(k);
set<int> ans;
rep(i, m) {
cin >> a >> b >> c;
d[a].push_back(pp(c, b));
d[b].push_back(pp(c, a));
}
rep(i, k) {
cin >> t[i];
}
for (i = 1; i <= num; i++) {
DFS(i, 0, d, t, ans, dp);
}
cout << ans.size() << "\n";
for (auto it = ans.begin(); it != ans.end(); it++) {
cout << *it << " ";
}
printf("\n");
return 0;
}
Zu_rin