結果
問題 | No.92 逃走経路 |
ユーザー | tkmst201 |
提出日時 | 2017-04-30 10:30:24 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,263 bytes |
コンパイル時間 | 2,043 ms |
コンパイル使用メモリ | 161,856 KB |
実行使用メモリ | 4,480 KB |
最終ジャッジ日時 | 2023-10-11 23:31:35 |
合計ジャッジ時間 | 2,697 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 2 ms
4,348 KB |
testcase_02 | AC | 2 ms
4,352 KB |
testcase_03 | AC | 2 ms
4,348 KB |
testcase_04 | AC | 2 ms
4,348 KB |
testcase_05 | AC | 2 ms
4,352 KB |
testcase_06 | AC | 2 ms
4,348 KB |
testcase_07 | AC | 2 ms
4,348 KB |
testcase_08 | AC | 2 ms
4,348 KB |
testcase_09 | AC | 7 ms
4,348 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; } template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; } typedef unsigned long long ull; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<int, pii> P; const ll INF = 1ll<<61; const ll MOD = 1000000007; const double EPS = 1e-10; int n, m, K; map<ll, vector<pii> > g; int main() { cin >> n >> m >> K; REP(i, m) { int a, b, c; scanf("%d %d %d", &a, &b, &c); a--; b--; g[c].push_back(pii(a, b)); g[c].push_back(pii(b, a)); } vector<int> ans; REP(i, n) ans.push_back(i); REP(i, K) { int d; scanf("%d", &d); vector<pii> &gn = g[d]; vector<int> now; REP(j, ans.size()) { REP(k, gn.size()) if (gn[k].first == ans[j]) { now.push_back(gn[k].second); break; } } ans = now; } sort(ALL(ans)); ans.erase(unique(ALL(ans)), ans.end()); cout << ans.size() << endl; REP(i, ans.size()) printf("%d%c", ans[i] + 1, i == ans.size() - 1 ? '\n' : ' '); return 0; }