結果
| 問題 |
No.92 逃走経路
|
| コンテスト | |
| ユーザー |
Sounds_Of_Rain
|
| 提出日時 | 2015-08-09 10:52:10 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 5,000 ms |
| コード長 | 1,248 bytes |
| コンパイル時間 | 616 ms |
| コンパイル使用メモリ | 86,364 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-18 06:10:08 |
| 合計ジャッジ時間 | 1,424 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <functional>
using namespace std;
typedef long long int llint;
const int INF = 1000000;
const llint LINF = 100000000;
int main() {
bool now[500], nex[500];
for (int i = 0; i < 500; i++) {
now[i] = 1;
nex[i] = 0;
}
int n, m, k;//n町m道路k料金個数;
cin >> n >> m >> k;
vector<int>a(m);
vector<int>b(m);
vector<int>c(m);
vector<int>d(k);
for (int i = 0; i < m; i++) {
cin >> a[i] >> b[i] >> c[i];
a[i]--;
b[i]--;
}
for (int i = 0; i < k; i++) {
cin >> d[i];
}
for (int i = 0; i < k; i++) {
for (int j = 0; j < m; j++) {
if (c[j] != d[i])continue;
else {
nex[a[j]] |= now[b[j]];
nex[b[j]] |= now[a[j]];
}
}
for (int w = 0; w < n; w++) {
now[w] = nex[w];
nex[w] = 0;
}
}
int ans = 0;
for (int i = 0; i < n; i++) {
ans += now[i];
}
cout << ans << endl;
for (int i = 0; i < n; i++) {
if (now[i]) {
if (--ans)cout << i + 1 << " ";
else {
cout << i + 1 << endl;
}
}
}
//cin >> n;
}
Sounds_Of_Rain