結果
| 問題 | No.92 逃走経路 |
| コンテスト | |
| ユーザー |
moti
|
| 提出日時 | 2015-07-17 18:20:50 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 37 ms / 5,000 ms |
| コード長 | 1,265 bytes |
| 記録 | |
| コンパイル時間 | 874 ms |
| コンパイル使用メモリ | 106,416 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-08 08:25:46 |
| 合計ジャッジ時間 | 1,649 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
using namespace std;
#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
int main() {
int N, M, K; cin >> N >> M >> K;
unordered_map<int, unordered_map<int, vector<int>>> cab;
rep(i, M) {
int a, b, c; cin >> a >> b >> c;
cab[c][a].push_back(b);
cab[c][b].push_back(a);
}
vector<int> d(K);
rep(i, K) {
cin >> d[i];
}
vector<int> now[1001];
rep(i, N) now[0].push_back(i+1);
rep(i, K) {
auto& ab = cab[d[i]];
rep(pre, N) {
vector<int> next;
rep(k, now[pre].size()) {
auto& tar = ab[now[pre][k]];
std::copy(tar.begin(), tar.end(), back_inserter(next));
}
std::sort(next.begin(), next.end());
next.erase(std::unique(next.begin(), next.end()), next.end());
now[pre] = next;
}
}
vector<int> ans;
rep(i, N) {
rep(j, now[i].size()) {
ans.push_back(now[i][j]);
}
}
std::sort(ans.begin(), ans.end());
cout << ans.size() << endl;
rep(i, ans.size()) {
if(i) cout << " ";
cout << ans[i];
}
cout << endl;
return 0;
}
moti